How to Get Body content of HTTPS using CURL How to Get Body content of HTTPS using CURL curl curl

How to Get Body content of HTTPS using CURL


Here is the solution:Try this, just keep rest of the coding same as above...

$ch = curl_init();curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_VERBOSE, 1);//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);curl_setopt($ch, CURLOPT_FAILONERROR, 0);// curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");curl_setopt($ch, CURLOPT_URL, $fullurl);$returned = curl_exec($ch);curl_close ($ch);var_dump($returned);

Changing CURLOPT_HEADER to 0 makes it so that only the page content is returned.


Shouldn't $fullurl be "https://www.queensberry.com" ?

When I changed $fullurl as stated and ran the code, var_dump displayed the "under construction" page.


if you still need the header, which means setting CURLOPT_HEADER to 0 is not an option, you can find the start of the body by looking for an empty line (two CRLF). See the spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html

so this should do the job:

    $data = curl_exec($ch);    $start = strpos($data, "\r\n\r\n") + 4;    $body = substr($data, $start, strlen($data) - $start);