【问题标题】:Ebay Auth token易趣认证令牌
【发布时间】:2015-07-29 11:27:35
【问题描述】:

我正在使用沙盒身份验证。令牌在这里,它总是向我发送这样的错误。

错误:身份验证令牌无效。 API 请求中的身份验证令牌验证失败。

但如果我使用我的生产验证。令牌它似乎在锻炼,完全没有问题。

我还检查了我的沙盒令牌的有效性,到期日期是 2016 年 11 月,这已经足够了。有人可以帮我解决我的问题吗?提前致谢。

代码如下:

require __DIR__.'/../vendor/autoload.php';

$config = require __DIR__.'/../configuration.php';

use \DTS\eBaySDK\Constants;
use \DTS\eBaySDK\Trading\Services;
use \DTS\eBaySDK\Trading\Types;
use \DTS\eBaySDK\Trading\Enums;

$service = new Services\TradingService(array(
    'apiVersion' => $config['tradingApiVersion'],
    'siteId' => Constants\SiteIds::US
));

$request = new Types\GetMyeBaySellingRequestType();

$request->RequesterCredentials = new Types\CustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = $config['sandbox']['userToken'];

$request->ActiveList = new Types\ItemListCustomizationType();
$request->ActiveList->Include = true;
$request->ActiveList->Pagination = new Types\PaginationType();
$request->ActiveList->Pagination->EntriesPerPage = 10;
$request->ActiveList->Sort = Enums\ItemSortTypeCodeType::C_CURRENT_PRICE_DESCENDING;

$pageNum = 1;

do {
    $request->ActiveList->Pagination->PageNumber = $pageNum;
    $response = $service->getMyeBaySelling($request);

echo "==================\nResults for page $pageNum\n==================\n";

if (isset($response->Errors)) {
    foreach ($response->Errors as $error) {
        printf("%s: %s\n%s\n\n",
            $error->SeverityCode === Enums\SeverityCodeType::C_ERROR ? 'Error' : 'Warning',
            $error->ShortMessage,
            $error->LongMessage
        );
    }
}

if ($response->Ack !== 'Failure' && isset($response->ActiveList)) {
    foreach ($response->ActiveList->ItemArray->Item as $item) {
        printf("(%s) %s: %s %.2f\n",
            $item->ItemID,
            $item->Title,
            $item->SellingStatus->CurrentPrice->currencyID,
            $item->SellingStatus->CurrentPrice->value
        );
    }
}

$pageNum += 1;

} while(isset($response->ActiveList) && $pageNum <= $response->ActiveList->PaginationResult->TotalNumberOfPages);

感谢大卫·T·萨德勒爵士

【问题讨论】:

    标签: php token trading ebay-api


    【解决方案1】:

    默认情况下,SDK 将连接到生产 API。如果您想使用沙盒 API,只需在创建 TradingService 对象时将 true 传递给 sandbox 配置选项。所有configuration options 的列表都可用。

    $service = new Services\TradingService(array(
        'apiVersion' => $config['tradingApiVersion'],
        'siteId' => Constants\SiteIds::US,
        'sandbox' => true
    ));
    

    【讨论】:

    • 感谢大卫的帮助。
    【解决方案2】:

    根据给出的信息,我几乎可以保证您将请求发送给

    https://api.ebay.com/ws/api.dll(这就是生产身份验证起作用的原因)

    而不是将其发送给

    https://api.sandbox.ebay.com/ws/api.dll(其中 Sandox 认证 应该工作)

    补充说明

    与生产相比,确保所有三个开发人员 ID 都是沙盒,因为它们确实不同

    另外应该注意的是,沙盒比生产环境有更多的错误,所以我个人只是使​​用生产环境来设置我的调用和东西。

    【讨论】:

    • 在这种情况下,您的请求代码也将非常有助于找出问题
    猜你喜欢
    • 1970-01-01
    • 2020-09-25
    • 2017-04-20
    • 1970-01-01
    • 2022-11-04
    • 1970-01-01
    • 2017-10-29
    • 2016-02-07
    • 2013-02-25
    相关资源
    最近更新 更多