使用ssl(HTTPs)网站的ex:https://www.eb2a.com
1-我尝试使用file_get_contents获取其内容,但无法正常工作并给出错误
例如:
<?php
$contents = file_get_contents("https://www.eb2a.com/");
echo $contents;
?>
2-我尝试使用fopen,但无法正常工作并给出错误
例如:
<?php
$url = 'https://www.eb2a.com/';
$contents = fopen($url, 'r');
echo "$contents";
?>
3-我尝试使用CURL,但无法正常工作并提供空白页
例如:
function cURL($url, $ref, $header, $cookie, $p){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_REFERER, $ref);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
if ($p) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $p);
}
$result = curl_exec($ch);
curl_close($ch);
if ($result){
return $result;
}else{
return '';
}
}
$file = cURL('https://www.eb2a.com/','https://www.eb2a.com/',0,0,null);
echo $file
任何人有任何想法?
解决方法:
要从安全的协议https获取内容,您需要从php.ini文件中启用openssl扩展,并对此进行身份验证.