how to get contents of site use HTTPS

你说的曾经没有我的故事 提交于 2019-12-31 02:28:06

问题


ex of site using ssl ( HTTPs ) : https://www.eb2a.com

1 - i tried to get its content using file_get_contents, but not work and give error ex :

<?php
$contents = file_get_contents("https://www.eb2a.com/");

echo $contents;
?>

2 - i tried to use fopen, but not work and give error ex:

<?php
$url = 'https://www.eb2a.com/';
$contents = fopen($url, 'r');
echo "$contents";
?>

3 - i tried to use CURL, but not work and give BLANK PAGE ex :

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

any one have any idea ??


回答1:


To fetch the contents from secure protocal https, you need to have openssl extenstion enabled from php.ini file and the authentication for that matter.



来源:https://stackoverflow.com/questions/2880169/how-to-get-contents-of-site-use-https

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!