fopen doesn't work with https

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alwaoul
Forum Newbie
Posts: 4
Joined: Wed Sep 02, 2009 12:31 pm

fopen doesn't work with https

Post by alwaoul »

I am trying to collect data from an https page using php.

When I run my php file with fopen("https://forums.sdn.sap.com/forum.jspa?f ... 97&start=0, "r") , I get the following message
Warning: fopen(https://forums.sdn.sap.com/forum.jspa?f ... 97&start=0) [function.fopen]: failed to open stream: No error in C:\xampp\htdocs\the_name_of_my_php_file.

I followed the instructions at http://www.leoganda.net/how-to-enable-x ... transport/
So I tried modifying my php.ini, and replacing libeay32.dll and ssleay32.dll as instructed. Now fopen works but instead of running the php file, all what is displayed is the homepage for the https i am interested in (i.e. I get defaulted to https://www.sdn.sap.com/irj/scn rather than display the content of https://forums.sdn.sap.com/forum.jspa?f ... 97&start=0)

Any suggestions?
alwaoul
Forum Newbie
Posts: 4
Joined: Wed Sep 02, 2009 12:31 pm

Re: fopen doesn't work with https

Post by alwaoul »

I think I made some progress. But I am still unsuccessful.

I am using curl commands instead of fopen. Yet I am still transferred to the default homepage https.

Here's the code (which I copied from a website):
$ch=curl_init() or die(curl_error());
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_URL, 'https://forums.sdn.sap.com/forum.jspa?f ... 97&start=0');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST,1);
$data1=curl_exec($ch) ;//or die(curl_error());
echo $data1;
Post Reply