编程语言
首页 > 编程语言> > php – Ebay Auth令牌

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
));

标签:php,token,ebay-api,trading
来源: https://codeday.me/bug/20190829/1763795.html