Saturday, March 5, 2011

Working with Channel Advisor API with PHP

Hello Guys,

Recently I was working with Channel Advisor(CA) API in PHP script. Script was built to get product information from CA and  update product information in CA. First of all lets see what is Channel Advisor platform?

It's a SaaS(Software As A Service) provider which enables retailers to sell products online through various channels like eBay, Amazon etc. It has certain features like product inventory using which retailer can store product information. Those products can be synchronized in various e commerce channels. User can track sales through each channel. Detailed reports are also available.

This platform is built upon .Net Framework and it offers Asp.Net web services to use its API. Using those web service we can use that platform from the third party application. To use web services you have to register as a developer and get developer key and password. After this channel advisor admin will approve your developer account and provides a account ID and local id that developer can use in the scripts. 

Now as we all know that Asp.Net web services use SOAP protocol so we need some soap client in PHP. PHP 5.1 and above has soap pears available while for older version one need to install it separately.

Following is the code to use CA web service.

$developerKey = 'your developer key';
$password = 'password';
$localID = '1111111050';
$accountID = 'account id';

$client = new SoapClient("");

$headersData = array('DeveloperKey' => $developerKey, 'Password' => $password);

$head = new SoapHeader("","APICredentials",$headersData);

That's it and you have Soap client available now you can call any method which is provided by web service. See the example below.
$result = $client->GetInventoryItemQuantityInfo(array('accountID'=>$accountID,'sku' => $sku));
Above code gives quantity of product specified by sku. 

So this is how you can integrate channel advisor API in PHP. Above example is of inventory service. There are other services also available. Each method in services needs some input. Some are the required fields like product SKU etc. for example cosider following example of SynchInventoryItem method. This is the method used to add or update product in inventory. While working in PHP all the parameters need to be sent in format of an array.

$iteminfo = array('Sku'=>$sku,

Then we need to send above array as a parameter in the method.

$arrData = array(
So this is how you can use CA API in PHP script.


  1. I have an account with ChannelAdvisor where daily there are some orders generated:

    I have developed some Zoho Creator forms to hold the data from these orders, manually.

    Now I am looking to use ChannelAdvisor API to let Zoho Creator automatically grab orders from ChannelAdvisor:

    Look in "Developer Network APIs".

    Can you guys help develop it?
    email 122.degrees attttt

  2. Hello Hiren ,

    I have used your sample code ..but it showing error .

    Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. Authorization failed.

    soap i enabled on my server.
    i tried other solution using nusoap.php and added the class in as soapclient_xxx
    then it showing soapclient_xxx class not found error.

    if (!extension_loaded('soap'))
    class soapclient_xxx extends nusoap_client {

    ..can you suggest any solution