我尝试做的只是简单地将我的商家信息从易趣上传到我的示例网站,我使用__GetSellerItem__
http://developer.ebay.com/DevZone/XML/docs/reference/ebay/GetSellerList.html。
但我想我缺乏如何输出或在我的网站上显示它。如果您似乎发现我的代码有一些错误,请随时说出来。我愿意为您考虑。
提前致谢。
//show all errors - useful whilst developing
error_reporting(E_ALL);
require 'vendor/autoload.php';
use \DTS\eBaySDK\Constants;
use \DTS\eBaySDK\Trading\Services;
use \DTS\eBaySDK\Trading\Types;
// Create the service object.
$service = new Services\TradingService(array(
'apiVersion' => '863',
'sandbox' => true,
'siteId' => Constants\SiteIds::US
));
// Create the request object.
$request = new Types\GetSellerListRequestType();
$request->RequesterCredentials = new Types\CustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = 'I have this one';
// Send the request to the service operation.
$response = $service->getSellerList($request);
答案 0 :(得分:1)
我已经扩展了您的示例代码,以便通过 GetSellerList 操作返回的项目进行分页。
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' => '921',
'siteId' => Constants\SiteIds::US
));
$request = new Types\GetSellerListRequestType();
$request->RequesterCredentials = new Types\CustomSecurityHeaderType();
$request->RequesterCredentials->eBayAuthToken = '<YOUR PRODUCTION AUTH TOKEN>';
/**
* The API does not return all the information available. This is to keep the size of the response small.
* Since we want to display the title and price information we have to request that this is returned.
*/
$request->DetailLevel[] = 'ItemReturnDescription';
/**
* Ask for items that started in the last 30 days.
*/
$request->StartTimeFrom = (new \DateTime('now', new \DateTimeZone('UTC')))->modify('-30 days');
$request->StartTimeTo = new \DateTime('now', new \DateTimeZone('UTC'));
/**
* Request that we would like the information returned 100 entries to a page.
*/
$request->Pagination = new Types\PaginationType();
$request->Pagination->EntriesPerPage = 100;
$pageNum = 1;
do {
$request->Pagination->PageNumber = $pageNum;
$response = $service->getSellerList($request);
echo "==================\nResults for page $pageNum\n==================\n";
/**
* Display any errors returned by the API.
*/
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') {
/**
* Iterate through the array of items that was returned.
*/
foreach ($response->ItemArray->Item as $item) {
printf("(%s) %s: %s %.2f\n",
$item->ItemID,
$item->Title,
$item->SellingStatus->CurrentPrice->currencyID,
$item->SellingStatus->CurrentPrice->value
);
}
}
/**
* Continue requesting pages of information until no more are returned.
*/
$pageNum += 1;
} while(isset($response->ItemArray) && $pageNum <= $response->PaginationResult->TotalNumberOfPages);