Libcurl problems
| From: | Jason Murray | Date: | Tue, 10 Apr 2001 03:03:34 +0000 |
| Subject: | Libcurl problems | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-47929@lists.php.net to get a copy of this message | ||
Hi everyone,
I'm having a few issues with libcurl.
Judging from what I've seen in the PHP manual, this should work:
<?
$curlerrors = fopen("/tmp/curlerrors", "a");
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://www.inww.com"); // Destination
URL
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // Output to a
variable
curl_setopt($curl, CURLOPT_POST, 1); // Use HTTP POST
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // Follow
"Location: " hints.
curl_setopt($curl, CURLOPT_STDERR, $curlerrors); // Error Log
curl_setopt($curl, CURLOPT_HEADER, 0); // Include
Headers
curl_setopt($curl, CURLOPT_TIMEOUT, 20); // Default
Timeout
curl_setopt($curl, CURLOPT_POSTFIELDS, "a=b&c=d"); // Post Varaibles
$data = curl_exec($curl);
curl_close($curl);
var_dump($data);
?>
The problem is that this seems flaky. Sometimes it'll do something in the
resulting page (I can tell this by whether the var_dump happens), other
times I get absolutely nothing (not even the var_dump, which means it's
bailing somewhere in the loop).
I've looked in /tmp/curlerrors, and there's nothing.
Can anyone help please? This is a tad frustrating... I'm sure I've
just done something stupid.
Jason
--
Jason Murray
jasonm@melbourneit.com.au
Web Design Team, Melbourne IT
Fetch the comfy chair!