易趣 SalesMaximizerAPI PHP 示例

Ebay SalesMaximizerAPI PHP sample

我正在为 ebay 寻找 PHP Sales Maximizes API 样品。 (正式名称为 Related Items API)。

但是,与其他 eBay API 不同,此特定 API 的详细信息似乎比较分散。是否有一个简单的 PHP 调用来创建产品包或获取产品包的来源?

如果您熟悉为 PHP 使用 Composer,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
        );
    }
}