Saturday, January 12, 2008

Nusoap php class and Godaddy.com hosting - CURL Settings!

I spent way too many hours trying to figure out how to get nusoap class to work on one of my godaddy accounts. It is actualy fairly simple, but not all too clear at first. It ends up being that nusoap.php classes are dependent on curl. Although curl is in fact instated on Godaddy, it isn't clear at first that you will need a proxy in order to get curl to work for you. If you start searching deep in the godaddy help, you will find examples on how to use curl, but it wasn't obvious (to me at least) that

in most cases, all you need to do is add this bit of code.

curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($ch, CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128");


this is a full example using curl
$URL="https://www.paypal.com";
if (isset($_GET["site"])) { $URL = $_GET["site"]; }
$ch = curl_init();
echo "URL = $URL
\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 "

\n";
echo 'Errors: ' . curl_errno($ch) . ' ' . curl_error($ch) . '

';
echo "

\n";
curl_close ($ch);
print "result - $result";
echo "

\n";


now to get nusoap working...
go into nusoap.php
search for curl in text

you will find where curl options are set in this document,
just add the two lines of code

curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt ($ch, CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128");

now nusoap class show work for you on godaddy.com. Hope it saves you a few hours. Now please be kind and visit http://www.ChaoSearch.com comparison engine or at least click a google ad :).

Labels: , , , , , , ,