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.

Step 1. Download the API Kit


The SOAP API Kits have been deprecated. We recommend using the HTTP API instead. See details

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 September, 2009).


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\"
int 123
HashMap (Datatype for storing name-value pair) array(""=>"1")
Array and Vector (Datatype for storing more than one value) array("","")
boolean (Datatype for storing true or false) true / false


  • 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\",1);

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.


  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.


    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 https://yourserver/examples/html and choose the required function from the links given in the left frame.

    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.

    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:

    1. Include the appropriate PHP Class file as below -


    2. Obtain a pointer to the required Class. This is done by using the code below -

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

    3. 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);


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


    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


    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.


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