douran7929 2016-05-26 08:47 采纳率: 100%
浏览 70

使用cURL的eBay API ReviseItem调用返回严重错误#5和#10012

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.

  • 写回答

1条回答 默认 最新

  • dongsu7049 2016-05-26 09:58
    关注
    #10012 Serious error: Invalid value for header "replaceable_value". 
    

    I just had to inspect the element locally (F12 on browser) and it says that the error comes from the API detail level.

    I added the following config line to the headers:

    X-EBAY-API-DETAIL-LEVEL: 0;
    

    and error #10012 seems to be solved.

    Error #5 appeared because i was sending the XML to eBay servers the wrong way. I just had to pass the string to the cURL as a parameter:

    curl_setopt($connection, CURLOPT_POSTFIELDS, $stringXML);
    

    instead of trying to parse it into an XML object.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大