GoDaddy, cURL, HTTP, and 403 Errors

By  on  

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.

Recent Features

  • By
    Introducing MooTools Templated

    One major problem with creating UI components with the MooTools JavaScript framework is that there isn't a great way of allowing customization of template and ease of node creation. As of today, there are two ways of creating: new Element Madness The first way to create UI-driven...

  • By
    Create a Sheen Logo Effect with CSS

    I was inspired when I first saw Addy Osmani's original ShineTime blog post.  The hover sheen effect is simple but awesome.  When I started my blog redesign, I really wanted to use a sheen effect with my logo.  Using two HTML elements and...

Incredible Demos

  • By
    Facebook-Style Modal Box Using MooTools

    In my oh-so-humble opinion, Facebook's Modal box is the best modal box around. It's lightweight, subtle, and very stylish. I've taken Facebook's imagery and CSS and combined it with MooTools' awesome functionality to duplicate the effect. The Imagery Facebook uses a funky sprite for their modal...

  • By
    Using jQuery and MooTools Together

    There's yet another reason to master more than one JavaScript library: you can use some of them together! Since MooTools is prototype-based and jQuery is not, jQuery and MooTools may be used together on the same page. The XHTML and JavaScript jQuery is namespaced so the...

Discussion

  1. Yea Godaddy has some strange settings like this. Plus it seems to be hit or miss when dealing with their support. :(

  2. cURL and GoDaddy

    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.

    Proxy servers are not required for
    outbound shared hosting connections as
    of September 10, 2008. Although it
    will continue to function after this
    date, we recommend code utilizing
    proxy servers be updated to reflect
    this change.

    http://help.godaddy.com/article/4764

  3. 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.

  4. My problem with SSL and POST through CURL alsted 2 days, i am not on GoDaddy but your advice gave me the answers I needed, thankyou so much for bothering to post this!

  5. Hi,

    We are trying to retrieve XML from other server using CURL. But not happening. I have tried the above code. But no result. I am using Godaddy Linux Shared Hosting plan for my website.

    Please give me your suggestions on this.

    Thanks in advance…

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!