简体   繁体   中英

I am trying to open a https site , using curl in php . But I am getting a blank page

I am trying to open a https site , using curl in php . But I am getting a blank page .Though when i checked I can find that the httpcode returned is 200. I am able to open the same page using the browser . I have disbaled the ssl verifyer and ssl_verify host since the host name and the name in the certifcate was different .

Here is my code any help would be useful

<?php
$url = "https://abcde.com/";
$ch = curl_init($url);
echo "init";
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 200);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERPWD,"uname:pwd");
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,1);
$curl_scraped_page= curl_exec($ch);
$httpCode=curl_getinfo($ch, CURLINFO_HTTP_CODE); 
if(!$curl_scraped_page)
{
    echo "first learn";
}
echo $httpCode ;
echo $curl_scraped_page;
curl_close($ch);
?>

Try using CURLOPT_USERAGENT to set the user agent to the same one your browser uses. They may be using user agent sniffing.

设置此选项:

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM