2017-02-08 29 views
-1

我正在尋找ebay的Sales Maximizes API上的PHP示例。 (正式稱爲相關項目API)。Ebay SalesMaximizerAPI PHP示例

然而,對於這個特殊的API的細節似乎要散不像其他的eBay API的。是否有一個簡單的PHP調用來創建產品包或獲取產品包的源代碼?

+0

發現請仔細閱讀[我可以問什麼議題有關(http://stackoverflow.com/help/on-topic) 和[如何問一個好問題](http://stackoverflow.com/help/how-to-ask) 和[完美的問題](http://codeblog.jonskeet.uk/2010/08/29/寫完美的問題/) – RiggsFolly

+0

感謝評論@RiggsFolly。請閱讀[我如何寫出一個好的答案](http://stackoverflow.com/help/how-to-answer):-) – hitwill

+0

我做了,感謝您的評論。但這是問題。 _Questions要求我們推薦或找到一本書,工具,軟件庫,教程或其他非現場資源,因爲它們傾向於吸引自以爲是的答案和垃圾郵件,所以不適合堆棧溢出。相反,描述問題___和迄今爲止已經做了什麼來解決它.___ – RiggsFolly

回答

0

如果您熟悉使用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 
     ); 
    } 
} 
+0

謝謝你太棒了!這正是我正在尋找的東西,而且我覺得捆綁軟件上的ebay文檔有點欠缺 – hitwill

+0

@ david-t-sadler這是一個非常棒的工具 - 但是,我似乎遇到了eBay中的以下錯誤: _未捕獲的異常 'GuzzleHttp \異常\ ServerException' 有消息「服務器錯誤:'POST https://開頭svcs.ebay.com /服務/ sellerinventory/V1/BundleManagementService'導致了'500內部服務器錯誤_ 有什麼想法嗎? – hitwill

+0

目前我建議您確保已使用正確的環境憑證。沙盒憑證和authtokens將無法在生產服務器上運行,反之亦然。 –