Curl Function in GoDaddy Hosting

I use GoDaddy Hosting for this site. A few days ago I tried to use the curl library. Curl was there - but all my calls timed out. I tried different approaches - but all failed. After some google searches I found out why - GoDaddy is using a proxy server.

So if you are using GoDaddy hosting and what to use curl, you should include these lines in the script...


<?php
curl_setopt
($chCURLOPT_PROXYTYPECURLPROXY_HTTP);
curl_setopt($chCURLOPT_PROXY,"http://64.202.165.130:3128");

...assuming that $ch is the curl handle.

A full example...


<?php
$url 
"http://www.google.com/";

$ch curl_init();
curl_setopt ($chCURLOPT_URL$url);
curl_setopt ($chCURLOPT_RETURNTRANSFER1);
curl_setopt ($chCURLOPT_PROXYTYPECURLPROXY_HTTP);
curl_setopt ($chCURLOPT_PROXY,"http://64.202.165.130:3128");
curl_setopt ($chCURLOPT_TIMEOUT120);
$response curl_exec ($ch);
if(
is_int($response)) {
    die(
"Errors: " curl_errno($ch) . " : " curl_error($ch));
}
curl_close ($ch);

print 
"Remote Site : $url<br /><hr />$response";
?>

Read more about using curl at the GoDaddy support pages...

blog comments powered by Disqus
Subscribe to Feed