My First Post      My Facebook Profile      My MeOnShow Profile      W3LC Facebook Page      Learners Consortium Group      Job Portal      Shopping @Yeyhi.com

Pages










Friday, December 16, 2011

PHP Curl not working on GoDaddy Host : why and Solution

Problem is that sometimes PHP Curl library not works on GoDaddy Host. Why curl is not working and how to solve this issue is what this post is all about.

I was trying to use curl library in my php code. But was soon tired of seeing numerous failures. My code was pretty much neet [those who know me know that well. I like cleanliness!! ;) ].

Still I was getting timeouts or some or the other errors , as I tried playing between parametrs. It was after some research over the internet and the manual, I found out that the trouble was because of host. Actually, GoDaddy uses a proxy server.

Voila!! You got it!!

So now on, if anyone uses GoDaddy as host and wants to use the curl library in his codes, has to just tweak his code by some additional lines.

Let us assume that $hn is the curl handler.
Then you have to include this line in your PHP Code---
curl_setopt($hn, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($hn, CURLOPT_PROXY,"http://64.202.165.130:3128");



Lets see an example..

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

$hn = curl_init();
curl_setopt ($hn, CURLOPT_URL, $url);
curl_setopt ($hn, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($hn, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($hn, CURLOPT_PROXY,"http://64.202.165.130:3128");
curl_setopt ($hn, CURLOPT_TIMEOUT, 120);
$res = curl_exec ($hn);
if(is_int($res)) {
die("Error occured: " . curl_errno($hn) . " : " . curl_error($hn));
}
curl_close ($hn);

print "Target URL: " . $url . " " . $res;
?>


Now, you may as thanks click on few of the advertisements links. Do it man!!

11 comments:

  1. The Haryana Police exam is expected to be held in Feb 2017. The Haryana Police Exam date will be announced soon

    ReplyDelete
  2. There are so many platforms for website designing like static HTML, flash websites and many more. PHP is one such platform that effectively works the best for custom cutting-edge web solutions. Another major feature for opting PHP is the cost advantage. plakatų maketavimas

    ReplyDelete
  3. For this we give task based software engineer group to comprehend the need of a specific undertaking. Top Expert Cakephp Developers

    ReplyDelete
  4. In PHP you require investigating devices to find bumbles and sees, yet the issue is there are only two or three them open in connection with other programming lingos like Python.Why use Laravel

    ReplyDelete
  5. Under "reasonable use", certain employments of copyright material would not be encroaching, for example, use for scholarly purposes, news announcing and so on.https://www.apkmacpc.com/itools-crack/

    ReplyDelete
  6. I'm not reading your blog!! I am seeing your animation skill in programming.. wow! just amazing.

    Gypsum Design Price in BD

    ReplyDelete
  7. Ecotechnology is environmental consulting companies most aware about ecological systems. They provides different kinds of services related about this.

    ReplyDelete
  8. Diligent Security is a leading security company in Canada that provides top-notch security services and guard training. Safety & peace of mind.

    Security Services
    Ontario Security License
    Security Guard License Training

    ReplyDelete