cURL "Couldn't connect to host"
Posted: Mon Mar 19, 2012 5:20 am
Hi All
I'm struggling to get cURL working via a proxy server. Below is my code:
The result is always string(24)"couldn't connect to host" for the curl_error and bool(false) for the $ch
Even if i try http://google.com i get the same error
Any suggestions?
Thanks
Marinus
I'm struggling to get cURL working via a proxy server. Below is my code:
Code: Select all
<?php
if (extension_loaded('curl'))
{
$url = "myip:8080/httppost_test/recieve.php?tester=testcurl";
//$url = "http://www.google.com";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, false);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15); // timeout after 5 seconds
curl_setopt ($ch, CURLOPT_TIMEOUT, 30); // timeout after 30 seconds
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC|CURLAUTH_DIGEST|CURLAUTH_GSSNEGOTIATE|CURLAUTH_NTLM|CURLAUTH_ANY|CURLAUTH_ANYSAFE);
curl_setopt($ch, CURLOPT_PROXYPORT, 80);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, '[user]:[password]');
$result = curl_exec ($ch);
var_dump(curl_error($ch)); // for debugging
curl_close ($ch);
var_dump($result);
}
?>Even if i try http://google.com i get the same error
Any suggestions?
Thanks
Marinus