Problem with using php and curl to access an HTTPS page

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

Problem with using php and curl to access an HTTPS page

Post by alwaoul »

I am using curl commands to read the data from an https page (https://forums.sdn.sap.com/forum.jspa?f ... 97&start=0).

When I run the php file, the file starts executing and the commands are echoed. But then I get transferred to the default homepage (https://www.sdn.sap.com/irj/scn).

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;

If I use the same code and replace the url with an HTTP one, it works.

Can anyone help?
alwaoul
Forum Newbie
Posts: 4
Joined: Wed Sep 02, 2009 12:31 pm

Re: Problem with using php and curl to access an HTTPS page

Post by alwaoul »

Can anyone help? Please.
Post Reply