GoDaddy, cURL, HTTP, and 403 Errors
Written by David Walsh on October 28, 2008 · 3 Comments
I was recently coding PHP cURL functionality for a GoDaddy-hosted website and I kept running into an annoying 403 error. Essentially, GoDaddy's proxy server (which they force you to use for cURL) was giving me a "Forbidden" error and wasn't trying to hit the necessary server. Here's the code that GoDaddy tells you to use for cURL transactions:
$URL='https://www.paypal.com'; $ch = curl_init(); echo 'URL = $URL <br>n'; curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE); curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); curl_setopt ($ch, CURLOPT_PROXY,'http://proxy.shr.secureserver.net:3128'); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_URL, $URL); curl_setopt ($ch, CURLOPT_TIMEOUT, 120); $result = curl_exec ($ch); echo '<hr><br>n'; echo 'Errors: ' . curl_errno($ch) . ' ' . curl_error($ch) . '<br><br>'; echo '<hr><br>n'; curl_close ($ch); print 'result - $result'; echo '<hr><br>n';
The problem is that since I'm not using SSL in this instance, I don't need to use the following cURL option:
curl_setopt($ch,CURLOPT_HTTPPROXYTUNNEL, true);
Remember that if you receive this error from GoDaddy's server. Hopefully I save someone a bunch of time with this.
Yea Godaddy has some strange settings like this. Plus it seems to be hit or miss when dealing with their support. :(
Searching the GoDaddy FAQ/Help pages, it appears that as of September 10, 2008. GoDaddy is not longer requiring proxy connections to connect with CURL.
http://help.godaddy.com/article/4764
I wouldn’t trust the GoDaddy FAQ.
It’s horribly outdated.
I am switching to a VPS from a provider that I’ve known to be reliable, from GoDaddy.