eBay API UploadSiteHostedPictures调用提供了错误的错误

时间:2015-07-20 16:10:08

标签: php xml api curl ebay-api

我使用php和cURL与eBay api进行交互。

以下是我尝试使用eBay api和UploadSiteHostedPictures上传图片时收到的长错误消息:

  

API调用“GeteBayOfficialTime”无效或不受支持   释放。

完整错误对象:

  

object(SimpleXMLElement)#14(5){[“ShortMessage”] =>串(21)   “不支持的API调用。” [ “LongMessage”] => string(79)“API调用   “GeteBayOfficialTime”无效或在此版本中不受支持。“   [ “错误码”] => string(1)“2”[“SeverityCode”] => string(5)“错误”   [ “ErrorClassification”] => string(12)“RequestError”}

这没有意义,因为我不会打电话给GeteBayOfficialTime。这是我的代码。我显然已经取代了敏感数据。

$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml .= '<UploadSiteHostedPicturesRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
$xml .= '<RequesterCredentials>';
$xml .= '<eBayAuthToken>my token</eBayAuthToken>';
$xml .= '</RequesterCredentials>';
$xml .= '<ExternalPictureURL>http://www.website.com/randompicture.jpg</ExternalPictureURL>';
$xml .= '<PictureName>My Picture Name</PictureName>';
$xml .= '</UploadSiteHostedPicturesRequest>';

$headers = array(
    'X-EBAY-API-COMPATIBILITY-LEVEL: 929',
    'X-EBAY-API-CALL-NAME : UploadSiteHostedPictures',
    'X-EBAY-API-DEV-NAME:hidden',
    'X-EBAY-API-APP-NAME:hidden',
    'X-EBAY-API-CERT-NAME:hidden',
    'X-EBAY-API-SITEID: 0',
    'Content-Type: text/xml;charset=utf-8'
);

$session  = curl_init('https://api.ebay.com/ws/api.dll');
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_HTTPHEADER, $headers);
curl_setopt($session, CURLOPT_POSTFIELDS, $xml);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

$responsexml = curl_exec($session);
curl_close($session);         
$response = new SimpleXMLElement($responsexml);
var_dump($response);

我使用API​​测试工具运行相同的请求,它运行正常,没有错误 - https://developer.ebay.com/DevZone/build-test/test-tool/default.aspx

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

简单的错误。标题在键和值之间不能有空格。

$headers = array(
    'X-EBAY-API-COMPATIBILITY-LEVEL:929',
    'X-EBAY-API-CALL-NAME:UploadSiteHostedPictures',
    'X-EBAY-API-DEV-NAME:hidden',
    'X-EBAY-API-APP-NAME:hidden',
    'X-EBAY-API-CERT-NAME:hidden',
    'X-EBAY-API-SITEID:0',
    'Content-Type:text/xml;charset=utf-8'
);