Archive for the ‘https’ tag
php获取https下的内容
直接用file_get_contents,
$url = ('https://xxx.com"); file_get_contents($url);
会报错;
Warning: file_get_contents(https://xxx.com) [function.file-get-contents]: failed to open stream: No such file or directory in D:wampwwwgrabber_clientindex.php on line 3
用curl的方式是可以的:
<?php $url = ('https://xxx.com'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $result = curl_exec($ch); print_r($result); ?>
重点是以下两句:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
snoopy https 问题的解决
今天在使用snoopy进行https的post请求,开始无法正常使用,有两个问题,因为https使用curl命令所以要安装并设置对。
var $curl_path = “/usr/local/bin/curl”; 这里设置对你的路径。
由于https默认都是443,snoopy似乎没有进行处理。
解决办法在所有case “https”:下面增加
$this->port = 443;

