DirectI API and NuSoap Problems (and My Fix)

I’ve been struggling the past few days with getting the directI/resellerclub/whatever they are calling themselves now API to work. Much of my struggle laid with the SOAP/XML aspect.  I kept getting errors like “Error: no transport found, or selected transport is not yet supported!”, Fatal errors about class soapclient not being able to be redifined. or blank pages.

I’d downloaded the PHP Domain Kit from resell.biz/us2.net (where I have my account with) and was attempting to use that.  IMHO, the PHP kit is garbage; the only good thing you can get from that are the .wsdl files.

So what was my fix? It was so simple I couldn’t believe it! I went to SourceForge and downloaded the most recent release of NuSoap (0.7.3 as of this post), extracted the nusoap.php file from there and placed it in the directory where the old nusoap.php file was located.

After doing that, I renamed any calls utilizing soapclient_w (which is what I’d renamed class soapclient in old nusoap.php after getting the redefined error mentioned above) with nusoap_client, and it worked!

Here’s how my code looks now:

//Include the nusoap and apiutil files. I use CodeIgniter, so APPPATH is already predfined. Replace APPPATH as needed for your code so it has the correct path.
include_once(APPPATH."libraries/domains/nusoap.php");
include_once(APPPATH."libraries/domains/apiutil.php");

//This particular chunk of code will check for domain availability, but the same principle applies to pretty much all of the classes/calls. Reference the PHP files included in the DomainsKit example files to apply the appropriate apiutil function as needed. The "TRUE" refers to defining whether or not you want the API to return alternate name suggestions
$parameters = array("reseller@username.here", "reseller_password", "reseller", "en", "parent_id_here", getArrayFromString("domains,to,check,separated,by,commas"), getArrayFromString("tlds,separated,by,comas"), "TRUE");
//$this->wsdl is defined earlier in my class. It's just the server path to the .wsdl files
$directi = new nusoap_client($this>wsdl."DomOrder.wsdl","wsdl");

//For some reason, this needs to be set prior to the call() function being called. Right now it is pointing at the demo server.
$directi->endpoint = "http://api.onlyfordemo.net/anacreon/servlet/APIv3";

$result = $directi->call("checkAvailabilityMultiple",$parameters);

(If you’re getting weird block-looking thingies, it’s thanks to wordpress’s filtering. Visit http://codesnippets.joyent.com/posts/show/1931 to see it in better form).

Hopefully this well help anyone trying to utilize DirectI’s API! 🙂

Advertisements
Previous Post
Leave a comment

1 Comment

  1. Last year for a project involving travelport xml api integration, we badly needed the soap requests to be gzipped, since the technical support people suggested.

    http://www.php-trivandrum.org/tips/gzip-nusoap-requests.html

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: