Domain Reseller, Domain Reseller Program, Domain Name Resellers

Become a Domain Reseller
 

Support Knowledge Base >> Reseller Guides >> Reseller API Guide >> PHP API Kit

Search |

PHP API Kit and Integration Guide

Follow the instructions below to begin integration with the API using PHP -

Make sure you have read the General API Integration Instructions first. If you have already integrated the PHP API Kit at your end, read the Change Log first to know what has changed since.

Reference:

General API Integration Instructions >>
Change Log >>

IMPORTANT

The PHP API Kit is not compatible with version PHP5. You need to use version PHP4 in order to integrate the API Kit at your end.

Step 1. Download the API Kit
Click the link below to download the relevant API kits (updated on 6th March, 2008).

PHP_CoreKIT_v3_10.zip
PHP_DomainsKIT_v3_10.zip
PHP_HostingKIT_v3_10.zip
PHP_OtherProductsKIT_v3_10.zip

Step 2. Download the API Documentation
The complete documentation of all classes and methods available in the API can be found in the Docs below. The Docs below are javadocs, but the function names and explanations remain the same for all the platforms and the documentation is self explanatory. We recommend you download the docs and read through them completely once before you integrate your application (updated on 6th March, 2008).

Core_Docs_v3_10.zip
Domains_Docs_v3_10.zip (updated on 4th June, 2008)
Hosting_Docs_v3_10.zip
OtherProducts_Docs_v3_10.zip

IMPORTANT

Since "list" is a keyword in the PHP language, the "list()" methods in the various classes (in the PHP Kit) has been renamed to "listOrder()." However, the documentation still mentions the method name as "list" since the documentation is JAVA specific.

 

Instructions to pass parameters to functions using the PHP Kit

Since PHP uses typeless variables you will have to ignore the datatypes presented in the docs. But for assigning values to variable of types other than strings and integers special care will have to be taken. Below is the list of datatypes presented in the API Doc and their usage in PHP.

Java Data

Types Assigning values in PHP

String "firstname\@secondname.com"
int 123
HashMap (Datatype for storing name-value pair) array("domain.com"=>"1")
Array and Vector (Datatype for storing more than one value) array("ns1.domain.com","ns2.domain.com")
boolean (Datatype for storing true or false) true / false

Example:

  • For Calling a Function which takes a String datatype and an integer datatype as its paramters

    public int function1(java.lang.String userName, int parentid)
    $result = $obj->function1("firstname\@secondname.com",1);

     

  • For Calling a Function which takes a HashMap, a String Array and an integer Array as its parameters

    public java.util.HashMap function2(java.util.HashMap domainHash, java.lang.String[] orderby, int[] resellerId)

    and domainHash is accepting the domainname and the number of years as name value pair

    $result = $obj->function2(array("domain1.com"=>1,"domain2.com"=>2),array("column1","column2"),array(22,33))
     

  • For Calling a Function which takes a Vector and a boolean as its parameters

    public java.lang.String function3(java.util.Vector nameServers, boolean add)
    $result = $obj->function3(array("ns1.domain.com","ns2.domain.com"),true)

 

Step 3. Extract the files from the API Kit archive
You should get the following directory & files structure

examples/ - Pre-written examples. You can directly run these examples to test API functionality
lib/ - The PHP class files, library files and wsdl files that you need to run your application
 

Step 4. Run the examples
You can run the pre-written examples provided in the "examples" folder. Note the following steps to do so -

1. Upload the "examples" and "lib" folders to your web server where you run your PHP scripts. Make sure that both these folders are uploaded to the same parent folder.

2. You must have PHP 4 installed on the server

3. You must have a Demo account ready the first time. Read the General instructions if you have not yet setup your demo account. Reference: General API Integration Instructions >>

IMPORTANT

The Demo server duplicates all functionality of the live server, however all Domain Names will appear as available on the Demo Server. It does not query the live registry and therefore names which are not available on the live registry will still appear as available on the Demo Server. At times connectivity to the DEMO Registry may be down resulting in errors.

4. Make the appropriate changes to "constants.php" in the "examples" folder, by putting in the values for your "SERVICE_USERNAME", "SERVICE_PASSWORD", "SERVICE_PARENTID". The remaining settings have already been made for you in this file. You may only need to change the path for the "lib" folder if you have uploaded the lib folder elsewhere

5. The URL to which the call is made is maintained in the "config.php" file inside the "lib" folder. By default all calls are made to the demo server URL using HTTP. You can make changes to this file and redirect your calls to the appropriate server

IMPORTANT

If you are using HTTPS calls you MUST have the extension for CURL installed and enabled in your PHP installation.

6. Another important parameter maintained in the "config.php" file is the variable $DEBUG. If this variable is set to "true", then for each call you will see the entire XML Request and Response in the output. You should keep it to "true" during testing, but set it to false on the live environment.

7. Every Example file has a set of functions which you can run.

8. Once you have modified the appropriate example file, access it over your webserver by putting in your URL such as http://yourserver/examples/html and choose the required function from the links given in the left frame.

IMPORTANT

In registering/managing any domain name on the demo server always use ns1.onlyfordemo.net and ns2.onlyfordemo.net as your nameservers. ANY OTHER Nameserver will result in an INVALID NAMESERVER error.

Step 5. Understanding Errors
Make sure you have read the General API Integration Instructions to obtain links to the error format and possible error documents. Reference:
General API Integration Instructions >>
 

Step 6. Writing your own code
After running each example above, if you simply refer to the corresponding .php file in the examples folder you will easily be able to figure out the code snippet you need to write in order to make a similar call.

Making an API call to perform any action is a matter of three steps:

(i) Include the appropriate PHP Class file as below

include($LIB_DIR."Order.class.php");

(ii) Obtain a pointer to the required Class. This is done by using the code below

$serviceObj = new Order($LIB_DIR . "wsdl/Order.wsdl");

(iii) Call the required method on this object. A complete reference of all methods is available in the Docs folder. This can be achieved by using the code below

$AssociativeArray = $serviceObj->setCustomerLock($SERVICE_USERNAME, $SERVICE_PASSWORD, $SERVICE_ROLE, $SERVICE_LANGPREF, $SERVICE_PARENTID, $orderId);

IMPORTANT

You will notice above that EVERY method in the docs takes the same first 5 parameters as below

String SERVICE_USERNAME, String SERVICE_PASSWORD, String SERVICE_ROLE, String SERVICE_LANGPREF, int SERVICE_PARENTID

In the examples these parameters have been put into a single constants file from which they are accessed by including the constants file. These parameters are common no matter which method you call. These parameters mean the following:

String SERVICE_USERNAME: Your Username
String 
SERVICE_PASSWORD: Your Password
String 
SERVICE_ROLE: This will always be a string "reseller"
String 
SERVICE_LANGPREF: The 2 letter code of the language in which you wish to receive errors and descriptions - "en" for English
int 
SERVICE_PARENTID: The ID of your parent which you can get from your profile section

IMPORTANT

Remember, when passing numerical data in hashtables, please ensure that the number is passed as a String.


Step 7. Change the information to Live information when you are ready

Once you have followed the steps above and got the test examples to work successfully, you can duplicate the same code in your live application and replace the Demo Server and Reseller account information with your live username and password. The URL that you make your calls to also needs to change to the LIVE Server URL. You will make this change in the "config.php" file in the "lib" folder

Once again note,
if you are using the HTTPS URL you MUST have the extension for CURL installed and enabled in your PHP installation.

 

Created on:  
Oct 29, 2003 4:11 PM  GMT
Last Updated on:   Jun 4, 2008 8:22 AM  GMT
 
Answer Change Log 
Answer PHP API Kit and Integration Guide 
Answer Common API Examples and Errors