Dashboard > ChannelAdvisor Developer Network > ... > Inventory Service Examples > PHP GetInventoryQuantity
Log In   View a printable version of the current page.
PHP GetInventoryQuantity
Added by Greg Smith, last edited by Greg Smith on Feb 14, 2008  (view change)
Labels: 
(None)


Thanks to Aaron Shershow for posting this sample!

Here's the code for the "GetInventoryQuantity" Function:

*********

Download the nusoap file here: http://sourceforge.net/projects/nusoap/

Make the following changes:

Line 3198 - Rename "soapclient" to "soapclient_xxx"

Line 7990 - Rename "soapclient" to "soapclient_xxx"

PHP Code:

<?php
//Initialize test variable
$sku = 'zz-cf002-e';
//Create the XML set
require_once('nusoap.php');
$client = new soapclient_xxx('https://api.channeladvisor.com/
ChannelAdvisorAPI/v1/inventoryService.asmx?WSDL', true );
$err = $client->getError();
if ($err)
{
echo 'Constructor error' . $err . '';
}
$developerKey = 'XXX';
$password = 'XXX';
$headers = '<APICredentials xmlns="http://api.channeladvisor.com/
webservices/">
      <DeveloperKey>'.$developerKey.'</DeveloperKey>
      <Password>'.$password.'</Password>
      </APICredentials> ';
$arrData = array('accountID'=>'XXX', 'sku'=>$sku);
// Call the SOAP method and send
$result = $client->call('GetInventoryQuantity', $arrData, false,
false, $headers);
//Print out the results
if ($client->fault)
{
echo 'Fault';
print_r($result);
echo '';
}
else
{
$err = $client->getError();
if ($err)
{
echo 'Error' . $err . '';
}
else
{
echo 'Result';
print_r($result);
echo '';
}
}
echo "<hr>";
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</
pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</
pre>';
?>
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.1 Build:#806 May 06, 2007) - Bug/feature request - Contact Administrators