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!!
Learning with learners
W3LC brings you Discussions For IT People. Stuffed with personal touch & humor by Anwar Jamal Faiz.
A great place to read and participate in IT discussions. With over 1.5 million hits from bright technical minds across the globe, W3LC urges to read, enjoy, and comment. Learning, ofcourse, would just be a side-effect. Also visit MeOnShow. And, Technology Job Puzzles.
Subscribe to:
Post Comments (Atom)
The Haryana Police exam is expected to be held in Feb 2017. The Haryana Police Exam date will be announced soon
ReplyDeleteExcellent informative blog, keep for sharing.
ReplyDeleteBest System Integration services | Massil Technologies
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
ReplyDeleteWow! Great article! It inspired me to make my own blog
ReplyDeleteWeb Hosting in Pakistan
One of the best blog posts I've read! Thanks a ton for sharing this!
ReplyDeleteWeb Hosting in Malaysia
For this we give task based software engineer group to comprehend the need of a specific undertaking. Top Expert Cakephp Developers
ReplyDeleteIn 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