anyone having problems with cURL and php 5.3.3?
| From: | J. Adams | Date: | Tue, 15 Feb 2011 21:15:55 +0000 |
| Subject: | anyone having problems with cURL and php 5.3.3? | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-7989@lists.php.net to get a copy of this message | ||
I'm having trouble using cURL functions with my build of PHP 5.3.3. Despite the fact that this machine can ping various remote hosts (and the curl command works just fine from the command line), when I try to run this PHP script in response to an apache access, I get "couldn't resolve host".
<?php
$url = 'http://google.com';
$tmp_file_name = 'tmp'.microtime(true).'.txt';
$ch = curl_init()
or die('could not create curl obj');
$fp = @fopen($tmp_file_name, 'w')
or die('could not open file');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 8);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 16);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
if(curl_exec($ch) === false){
die(curl_error($ch));}else{
echo 'success!';} curl_close($ch); fclose($fp); ?> The script is basically trivial. curl_version() returns the following:
[version_number] => 462852
[age] => 3
[features] => 573
[ssl_version_number] => 0
[version] => 7.16.4
[host] => i386-apple-darwin9.0
[ssl_version] => OpenSSL/0.9.7l
[libz_version] => 1.2.3
[protocols] => Array
(
[0] => tftp
[1] => ftp
[2] => telnet
[3] => dict
[4] => ldap
[5] => http
[6] => file
[7] => https
[8] => ftps
)