【问题标题】:eBay API Oauth Refresh Token in PHPPHP中的eBay API Oauth刷新令牌
【发布时间】:2017-11-15 18:02:35
【问题描述】:

我目前正在尝试与 eBay API 集成,我已经设法手动集成它并手动输入 oAuth 密钥以提取数据。

我一生都无法使用 oAuth 刷新令牌,我不断收到来自 API 的最难以描述的错误消息,只是说“出现错误,请重试”。

我当前的代码如下 -

    function GetTokens($sessionid){
            // Create headers to send with CURL request.
$headers = array
(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Basic REMOVED'
);

$xml =  '<?xml version="1.0" encoding="utf-8"?>'.
    '<FetchTokenRequest xmlns="urn:ebay:apis:eBLBaseComponents">'.
         '<SessionID>' . $sessionid . '</SessionID>'.

   '</FetchTokenRequest>';

// Send request to eBay and load response in $response
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, $this->api_server . 
"/identity/v1/oauth2/token");
curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($connection, CURLOPT_POSTFIELDS, $xml);
curl_setopt($connection, CURLOPT_HTTPHEADER, $headers);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($connection);
curl_close($connection);
    print_r($response);
} 

任何帮助将不胜感激!

【问题讨论】:

    标签: php curl oauth ebay-api


    【解决方案1】:

    您至少可以停止对 API 撒谎。你告诉apii'm sending you some data in application/x-www-urlencoded format,然后以application/xml格式发送数据!也许这就是您收到神秘错误的原因。

    您还应该向他们的 bugtracker 投诉,如果他们有此错误,则该错误应该更具描述性(例如,failed to parse the request body as appliation/x-www-urlencoded, malformed syntax 以及 http 400 Bad Request 响应会很好)

    【讨论】:

    • 我从来没有使用过这么尴尬的 API,我已经给他们发了电子邮件。愚蠢的是,API 指定您需要同时发送!
    猜你喜欢
    • 2017-11-20
    • 2017-12-20
    • 2019-03-13
    • 2014-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-05
    • 1970-01-01
    相关资源
    最近更新 更多