ebay sdk - 检索订单并与外部数据库同步

ebay sdk - retrieving orders and sync with external DB

从字面上看,我正在努力弄清楚如何使用 Ebay API 来检索在特定商家帐户上收到的订单,然后将一些数据存储在外部数据库中。

我已经注册到 developer.ebay.it,我已经为生产和沙盒构建了一个密钥对,然后我尝试了 api (Browse/getItem)...然后...丢失。

我无法使用 Fullfillment,因为我总是得到授权不足的响应,即使我创建了一个令牌,即使我输入了真实的订单号......我不知道如何质疑 API.

最后,我正在使用 PHP 并且我已经从 github 下载了 davidtsadler SDK。如何使用该 SDK 配置 getOrder 示例?您有什么 link 的建议吗?

我在互联网上找到的内容对于我的知识水平来说还不够清楚,几乎没有人处理 getOrder 调用。

感谢您的帮助。

ebay API documentation 非常清楚如何执行查询:

如果您想获得特定的 Fullfillment 政策,则需要使用 /order/{orderId} 路径向 ebays Fullfillment API 执行 GET 请求 - 其中 {orderId}是一个真实的订单ID。

在 PHP 中, 可能会 有点像这样:

/* Returns a JSON object containing an ebay order */
function getOrder($order_id, $auth_key){
    $options = array(
            'http' => array(
                    'method' => "GET",
                    'header' => "Authorization: Bearer ".$auth_key."\r\n" .
                                "Content-Type: application/json"

        )
    );

    $context = stream_context_create($options);
    $result = file_get_contents("https://api.ebay.com/sell/fulfillment/v1/order/".$order_id, false, $context);
    return json_decode($result);
}

然后您可以调用上面的方法并使用以下方法检索订单:

$order = getOrder("A REAL ORDER ID", "YOUR AUTH KEY");

$order 变量现在包含一个 JSON 对象。您可以使用以下方法从对象打印信息:(此示例打印与订单关联的用户名)

echo $order->buyer->username;

最后,请注意直接引用ebays documentation

"eBay creates and displays an Application token. This token is valid for a limited time span. If you get an invalid token error when you make a call using this token, simply create a new token and use the new token in your call."