【发布时间】:2015-07-20 16:10:07
【问题描述】:
我正在使用 php 和 cURL 与 eBay api 交互。
这是我尝试使用 eBay api 和 UploadSiteHostedPictures 上传图片时收到的长错误消息:
API 调用“GeteBayOfficialTime”无效或不支持 释放。
完整的错误对象:
object(SimpleXMLElement)#14 (5) { ["ShortMessage"]=> 字符串(21) “不支持的 API 调用。” ["LongMessage"]=> string(79) "API 调用 “GeteBayOfficialTime”在此版本中无效或不受支持。” ["ErrorCode"]=> 字符串(1) "2" ["SeverityCode"]=> 字符串(5) "错误" ["ErrorClassification"]=> 字符串(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
任何帮助将不胜感激。
【问题讨论】: