FOPEN using https
Posted by: arnb (---.dyn.optonline.net)
Date: June 16, 2013 05:38PM

I'm attempting to read a Facebook page using https protocol with Fopen, and while I can read the page it is encrypted gibberish. Hopefully someone has figured this out. Please note this is a freely available page that works in any modern browser.

What I've done so far:
Enabled openssl in the php extensions
Faked the browser id to make facebook respond

I've added some SSL info I found on the web to the context options but it is not working. I'm guessing I have to generate and store a certificate but have no idea how to do that. I also have no idea what the capath should be in wamp.

Code Follows

$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0\r\n".
"Accept-language: en-US,en;q=0.5\r\n" .
"Accept-Encoding: gzip, deflate\r\n".
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"winking smiley,
'ssl'=>array('verify_peer'=>true, 'capath'=>'/etc/ssl/certs')
);

$context = stream_context_create($opts);
//echo print_r($context,true),

// Open the file using the HTTP headers set above
$handle = fopen('https://www.facebook.com/xxxxx', 'rb', false, $context);

if (!$handle)
{
echo '<br>fopen failed<br>';
return false;
}
$bdy = null;
while (!feof($handle))
{
$bdy .= fread($handle, 8192);
}
fclose($handle);

Options: ReplyQuote
Re: FOPEN using https
Posted by: stevenmartin99 (Moderator)
Date: June 16, 2013 07:40PM

that wont work

use curl

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: FOPEN using https
Posted by: arnb (---.dyn.optonline.net)
Date: June 17, 2013 07:23PM

Thank you. Found some good links for Curl and HTTPS and it's working.

[nadeausoftware.com]
[unitstep.net]

Options: ReplyQuote


Sorry, only registered users may post in this forum.