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($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); curl_setopt($ch, CURLOPT_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 ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); curl_setopt ($ch, CURLOPT_PROXY,"http://64.202.165.130:3128"); curl_setopt ($ch, CURLOPT_TIMEOUT, 120); $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...