我正在使用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
));
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。