如果您熟悉使用Composer for PHP,則可以在https://github.com/davidtsadler/ebay-sdk-php上找到SDK,這有助於使用eBay API。 (完全披露:我是SDK的作者)。
以下是如何使用相關項服務創建捆綁包的示例。爲了使用該示例,您需要開發人員的應用程序,證書和開發人員ID以用於沙箱環境。您還需要沙盒eBay賣家的授權令牌,您希望爲其創建捆綁銷售。
請注意,雖然SDK可以更輕鬆地與API集成,但它不會教會您有關它的所有信息。閱讀createBundles操作的文檔以查看可用的字段和選項很重要。如何找到並刪除束
的例子也可在其https://github.com/davidtsadler/ebay-sdk-examples/tree/master/related-items
<?php
require __DIR__.'/vendor/autoload.php';
use \DTS\eBaySDK\Constants;
use \DTS\eBaySDK\RelatedItemsManagement\Services;
use \DTS\eBaySDK\RelatedItemsManagement\Types;
use \DTS\eBaySDK\RelatedItemsManagement\Enums;
/**
* Request to the API are made through a service object.
*/
$service = new Services\RelatedItemsManagementService([
'credentials' => [
'appId' => 'your-app-id',
'certId' => 'your-cert-id',
'devId' => 'your-dev-id'
],
'authToken' => 'your-auth-token',
'globalId' => Constants\GlobalIds::US,
'sandbox' => true
]);
$request = new Types\CreateBundlesRequest();
/**
* A bundle has a primary product and related products in the bundle.
*/
$bundle = new Types\Bundle();
$bundle->bundleName = "Example Bundle";
$bundle->primarySKU = ['123456789'];
$bundle->scheduledStartTime = new \DateTime('2017-03-01 00:00:00', new \DateTimeZone('UTC'));
$bundle->scheduledEndTime = new \DateTime('2017-03-07 00:00:00', new \DateTimeZone('UTC'));
/**
* Add two products that will be bundled with the main product.
*/
$group = new Types\RelatedProductGroup();
$group->groupName = "Example Group";
$product = new Types\RelatedProduct();
$product->SKU = 'AAABBBCCC';
$group->relatedProduct[] = $product;
$product = new Types\RelatedProduct();
$product->SKU = 'DDDEEEFFF';
$group->relatedProduct[] = $product;
$bundle->relatedProductGroup[] = $group;
$request->bundle[] = $bundle;
/**
* Send the request.
*/
$response = $service->createBundles($request);
/**
* Output the result of the operation.
*/
foreach ($response->bundleStatus as $bundleStatus) {
if ($bundleStatus->ack !== 'Failure') {
printf(
"Bundle Created (%s) %s\n",
$bundleStatus->bundleID,
$bundleStatus->bundleName
);
}
}
發現請仔細閱讀[我可以問什麼議題有關(http://stackoverflow.com/help/on-topic) 和[如何問一個好問題](http://stackoverflow.com/help/how-to-ask) 和[完美的問題](http://codeblog.jonskeet.uk/2010/08/29/寫完美的問題/) – RiggsFolly
感謝評論@RiggsFolly。請閱讀[我如何寫出一個好的答案](http://stackoverflow.com/help/how-to-answer):-) – hitwill
我做了,感謝您的評論。但這是問題。 _Questions要求我們推薦或找到一本書,工具,軟件庫,教程或其他非現場資源,因爲它們傾向於吸引自以爲是的答案和垃圾郵件,所以不適合堆棧溢出。相反,描述問題___和迄今爲止已經做了什麼來解決它.___ – RiggsFolly