|
Posted by BinnyVA on 11/05/06 18:25
Hi,
I am using PHP 5.1.2 with curl enabled. But whenever I try to use curl
to fetch a url, it fails - 'curl_exec()' returns nothing.
But if I try to execute the same file in CLI - like 'php curl.php', the
script works properly. However if I try it in a browser, nothing is
returned.
The code is...
curl.php
----
<?php
$ch = curl_init("http://localhost/");
curl_setopt($ch, CURLOPT_URL, "http://localhost/data.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //Just return the data
- not print the whole thing.
curl_setopt($ch, CURLOPT_HEADER, false); //We need the headers
curl_setopt($ch, CURLOPT_NOBODY, false); //The content - if true, will
not download the contents
print curl_exec($ch);
curl_close($ch);
----
--
Binny V A
http://www.bin-co.com/php/
[Back to original message]
|