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("https://api.channeladvisor.com/ChannelAdvisorAPI/v3/InventoryService.asmx?WSDL");
$headersData = array('DeveloperKey' => $developerKey, 'Password' => $password);
$head = new SoapHeader("http://api.channeladvisor.com/webservices/","APICredentials",$headersData);
$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.