我正在尝试将附属参数添加到我的脚本中,以便在ebay上查找项目,但我不明白我可以在哪里放联盟trackindId等
我尝试在服务请求$ service = new Services \ FindingService之后添加联盟营销活动ID但不起作用。
非常感谢任何帮助
require 'vendor/autoload.php';
use \DTS\eBaySDK\Constants;
use \DTS\eBaySDK\Finding\Services;
use \DTS\eBaySDK\Finding\Types;
$config = require 'configuration.php'; // Get configuration.php file
$service = new Services\FindingService(array(
'appId' => $config['ebay']['production']['appId'],
'apiVersion' => $config['ebay']['findingApiVersion'],
'globalId' => Constants\GlobalIds::IT
));
$request = new Types\FindItemsByKeywordsRequest();
$words = isset($_GET['search']) ? $_GET['search'] : "";
$request->keywords = $words;
$request->paginationInput = new Types\PaginationInput();
$entriesPerPage = 15; // Ebay items on the page
$request->paginationInput->entriesPerPage = $entriesPerPage;
$pageNum = isset($_GET['page']) ? $_GET['page'] : 1;
$request->paginationInput->pageNumber = (int)($pageNum);
$response = $service->findItemsByKeywords($request);
$responsePages = $response->paginationOutput->totalPages;
$currentPages = 20; // Total page: get 20. Maximum: 100 pages
$totalEbayPages = min($currentPages, $responsePages);
$totalEbayResult = isset($response->paginationOutput->totalEntries) ? $response->paginationOutput->totalEntries : 0;
$resultEbay = [];
if ($pageNum <= $totalEbayPages) {
if ($response->ack !== 'Success') {
if (isset($response->errorMessage)) {
foreach ($response->errorMessage->error as $error) {
printf("Error: %s\n", $error->message);
}
}
} else {
foreach ($response->searchResult->item as $key => $item) {
$resultEbay[$key]['title'] = $item->title;
$resultEbay[$key]['viewItemURL'] = $item->viewItemURL;
$resultEbay[$key]['galleryURL'] = isset($item->galleryURL) ? $item->galleryURL : '../images/iconPlaceholder_96x96.gif';
$resultEbay[$key]['priceId'] = $item->sellingStatus->currentPrice->currencyId;
$resultEbay[$key]['currentPrice'] = $item->sellingStatus->currentPrice->value;
$resultEbay[$key]['condition'] = strtolower(isset($item->condition->conditionDisplayName) ? $item->condition->conditionDisplayName : 'other');
$resultEbay[$key]['categoryName'] = isset($item->primaryCategory->categoryName) ? $item->primaryCategory->categoryName : 'none';
$resultEbay[$key]['shipping'] = isset($item->shippingInfo->shippingType) ? $item->shippingInfo->shippingType : 'free';
$resultEbay[$key]['shopName'] = 'at eBay';
if (isset($item->listingInfo->listingType)) {
if ($item->listingInfo->listingType == 'Auction') {
$resultEbay[$key]['pricing'] = $item->listingInfo->listingType;
} else {
$resultEbay[$key]['pricing'] = 'Buy Now';
}
}
}
}
}
答案 0 :(得分:0)
通过请求的affiliate field指定您的详细信息。
$request->affiliate = new Types\Affiliate();
$request->affiliate->customId = '...';
$request->affiliate->geoTargeting = true;
$request->affiliate->networkId = 2;
$request->affiliate->trackingId = '...';