// 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)
);
// Create shop item data
$description = 'Test item - Please do not buy';
$price = 7200;
$shopItem = new StdClass();
$shopItem -> Title = null;
$shopItem -> Price = $price;
$shopItem -> Description = $description;
/* We don't need to set values we do not wish to update
$shopItem -> CategoryId = null;
$shopItem -> AcceptedBuyerId = null; //international
$shopItem -> ShippingOptions = null;
$shopItem -> PaymentOptionIds = null;
$shopItem -> ItemAttributes = null; // 1=New, 2= Used
$shopItem -> ShippingCondition = null;
$shopItem -> PaymentConditions = null;
$shopItem -> OwnReferences = null; // Array of strings
$shopItem -> VAT = null; //
$shopItem -> ItemImages = null;
$shopItem -> ActivateDate = null;
$shopItem -> DeactivateDate = null;
$shopItem -> Quantity = null;
$shopItem -> ExternalId = null; // Array of strings
*/
$updateItem = new StdClass();
$updateItem -> ItemData = $shopItem;
$updateItem -> ItemId = 260205913; // ID of the item to be updated
$updateShopItemParams -> updateData = $updateItem;
// Make Soap call
$updateShopItemResult = $restrictedClient->UpdateShopItem($updateShopItemParams);
// Use the requestId to verify the request has been succesful
$requestId = $updateShopItemResult -> UpdateShopItemResult -> RequestId;
sleep(5);
$getReqResultsParams = new StdClass();
$getReqResultsParams -> requestIds -> int = array($requestId);
$requestResult = $restrictedClient -> GetRequestResults($getReqResultsParams);
$result = $requestResult -> GetRequestResultsResult -> RequestResult;
if($result -> ResultCode == 'Ok'){
echo 'SUCCES:' . PHP_EOL . $result -> Message . PHP_EOL;
}
else {
echo 'REQUEST NOT FINISHED:' . $result -> ResultCode . PHP_EOL;
echo $result -> Message;
}
}
catch(SoapFault $soapFault) {
echo 'Error: ' . $soapFault->faultstring;
}
|