I'm developing some PHP to work with the eBay API with cURL and I have tried this:
<?php
$dev_id = "sandboxDevId"; //Changed for security reasons
$app_id = "sandboxAppId"; //Changed for security reasons
$cert_id = "sandboxCertId"; //Changed for security reasons
$site_id = "186"; //spain
$xmlVersion = "1.0";
$encoding = "utf-8";
$api_endpoint = "https://api.sandbox.ebay.com/ws/api.dll";
$auth_token = "theAuthToken"; //The Auth token (Long String) for the seller user.
//I have changed it for the real token
$itemid = "110178474743"; //The item id in sandbox
$new_description = "Updating my item description with cURL";
$new_description = urldecode($new_description);
$stringXML = "<?xml version=\"".$xmlVersion."\" encoding=\"".$encoding."\"?>";
$stringXML .="<ReviseItemRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">";
$stringXML .="<ErrorLanguage>en_US</ErrorLanguage><Item><ItemID>".$itemid."</ItemID>";
$stringXML .="<Description>".$new_description."</Description>";
$stringXML .="</Item><RequesterCredentials>";
$stringXML .="<eBayAuthToken>".$auth_token."</eBayAuthToken></RequesterCredentials>";
$stringXML .="<WarningLevel>High</WarningLevel></ReviseItemRequest>";
$feed = new SimpleXMLElement($stringXML);
$headers = array
(
'X-EBAY-API-COMPATIBILITY-LEVEL: 963',
'X-EBAY-API-DEV-NAME: ' . $dev_id,
'X-EBAY-API-APP-NAME: ' . $app_id,
'X-EBAY-API-CERT-NAME: '. $cert_id,
'X-EBAY-API-CALL-NAME: ReviseItem',
'X-EBAY-API-SITEID: ' . $site_id,
);
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, $api_endpoint);
curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
curl_setopt($connection, CURLOPT_POST, 1);
curl_setopt($connection, CURLOPT_POSTFIELDS, $feed);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($connection);
curl_close($connection);
echo $response;
?>
I have tried to change the item description via the Developer tool and it worked, and I have printed the XML as plain text and it seems to be correct, but for some reason i get the following error:
2016-05-26 08:38:32 100121SeriousError00RequestError 51SeriousError00RequestError
It drops me two errors, i have checked them on the API reference:
#5 Serious error: XML Parse error.
and
#10012 Serious error: Invalid value for header "replaceable_value".
And i can't figure out how to solve that problems.
It will be helpful if someone can throw some light about this problem; It is the first time I work with cURL and XML and every help will be apreciated.