// Replace the following variables with your own key management
// $APPLICATION_KEY
// $TOKEN
// $USER_ID
// $APPLICATION_ID
try {
$appId = $APPLICATION_ID;
$userId = $USER_ID;
$token = $TOKEN;
$appKey = $APPLICATION_KEY;
$restrictedServiceUrl = 'https://api.tradera.com/v3/RestrictedService.asmx';
$restrictedServiceUrlWithAuth = $restrictedServiceUrl
. '?appId=' . $appId
. '&appKey=' . $appKey
. '&userId=' . $userId
. '&token=' . $token;
$restrictedClient = new SoapClient(
$restrictedServiceUrl . '?WSDL',
array('location' => $restrictedServiceUrlWithAuth)
);
// Manufacture data (itemId => new qty)
$itemsToUpdate = array(260143133 => 4, 260143133 => 0);
// Create shop item data
$setQtyRequest = new StdClass();
$setQtyRequest -> ShopItems = new StdClass();
$setQtyRequest -> ShopItems = array();
foreach ($itemsToUpdate as $itemId => $qty) {
$setQtyItem = new StdClass();
$setQtyItem -> Id = $itemId;
$setQtyItem -> Quantity = $qty;
array_push($setQtyRequest -> ShopItems, $setQtyItem);
}
$setQuantityOnShopItemsParams = new StdClass();
$setQuantityOnShopItemsParams -> request = $setQtyRequest;
// Make Soap call
$setQtyResult = $restrictedClient->SetQuantityOnShopItems($setQuantityOnShopItemsParams);
// Handle errors
$succesfulUpdates = $setQtyResult -> SetQuantityOnShopItemsResult -> SuccessfulUpdates;
if ($succesfulUpdates == count($itemsToUpdate)) {
echo "SUCCESS";
}
else {
foreach ($setQtyResult -> SetQuantityOnShopItemsResult -> ValidationErrors as $validationError) {
echo 'ERROR:' . PHP_EOL;
echo print_r($validationError);
}
}
}
catch(SoapFault $soapFault) {
echo 'Error: ' . $soapFault->faultstring;
}
|