0

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);
?>

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

3 Comments

HI , Thanks but could you please help me how can I get the user agent parameter of my current browser , I am using Safari on MAC OSx.
HI , Could you also help me since , i am able to open a site with the same browser so how can user agnet sniffing be a factor .
whatsmyuseragent.com . Take that value and use it to set CURLOPT_USERAGENT .
0

Set this option:

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.