Forum Moderators: coopster

Message Too Old, No Replies

php 4 vs 5 with cURL

         

tekomp

6:24 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



Hi,

I have a simple script that uses cURL to grab data from a server and display that in the browser. I can get it to work fine on servers with php4, but it won't display in the browser on servers with php5. It works for both through the shell though. Here is the cURL code:


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 90);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_str);
//curl_setopt($ch, CURLOPT_NOBODY, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, "x-www-form-urlencoded");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$res = curl_exec($ch);
curl_close($ch);


$resp = explode("\n\r\n", $res);
$header = explode("\n", $resp[0]);
$body = explode("&", $resp[1]);


echo "<pre>";
print_r($header);
print_r($body);
echo "</pre>";

Does anyone know why this would break in PHP 5?

Thanks.

jatar_k

7:35 pm on Apr 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



strange I can't see anything that jumps out at me

were these tested with the exact same page?
was the test exactly the same with the only difference being the php version?
did you view source to see if anything was there?
was it possibly a time out of the site trying to be grabbed?

did it work aside from the display?

tekomp

8:07 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



It turns out that it died on https and not http and had nothing to do with PHP5. Openssl 0.9.7d was causing a segfault with https. Upgraded to 0.9.8a and it works fine.

Thanks.