php – Ebay Auth令牌

我正在使用SandBox Auth.令牌在这里它总是发送给我一个这样的错误.

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

但如果我使用我的Production Auth.令牌似乎在锻炼,完全没有问题.

我还检查了我的SandBox令牌的有效性,截止日期是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);

致David S. Sadler先生的致谢

解决方法:

认情况下,SDK将连接到生产API.如果要使用沙箱API,只需在创建TradingService对象时将true传递给沙箱配置选项.可以获得所有configuration options的列表.

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

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...