lai3221/amzn_adv_api_php

亚马逊广告API客户端库V3.0

3.0.6 2024-06-19 06:13 UTC

This package is auto-updated.

Last update: 2024-09-19 06:50:37 UTC


README

logo

Total downloads Latest stable version License

概述

官方亚马逊广告API PHP客户端库。

版本 3.0 OAS 3.0.1

包含资源:推广产品V3(报告V3)
推广品牌V4(报告V2)
推广展示(报告V2)
账户
报告
商店
资产
受众发现(新功能)
变更历史V1(新功能)
帖子V2(新功能)
导出(新功能)
产品(新功能)

要求

PHP >= 7.3
cURL >= 7.18

文档

API参考
入门

教程

注册沙箱配置文件 - 这篇教程将向您展示如何使用CURL在沙箱中注册配置文件。
使用CURL生成和下载报告 - 在进行此教程之前,您需要完成在沙箱中注册配置文件。

沙箱自助服务

如果您想在沙箱中测试API,您需要为要测试的区域注册一个配置文件。可以通过执行registerProfile API调用来完成此操作。在执行此调用之前,请确保以sandbox模式实例化客户端,否则它将失败。

以下国家/地区代码可用于测试。

US, CA, UK, DE, FR, ES, IT, IN, CN, JP

快速入门

实例化客户端

如果您没有刷新令牌,可以传递accessToken

<?php
namespace AmazonAdvertisingApi;

require_once "src/Client.php";

$config = array(
    'clientId' => 'CLIENT_ID',
    'clientSecret' => 'CLIENT_SECRET',
    'region' => 'NA',
    'accessToken' => 'ACCESS_TOKEN',
    'refreshToken' => 'REFRESH_TOKEN',
    'sandbox' => false,
    'saveFile' => false,
    'apiVersion' => '',
    'sbVersion' => '',
    'spVersion' => '',
    'sdVersion' => '',
    'portfoliosVersion' => '',
    'reportsVersion' => '',
    'appUserAgent' => '',
    'deleteGzipFile' => false,
    'isUseProxy' => false,
    'guzzleProxy' => '',
    'curlProxyType' => 'socks5',
    'curlProxy' => '',
    'headerAccept' => ''
  );

$client = new Client($config);

刷新访问令牌

当访问令牌过期时,您可以使用以下方法刷新访问令牌。新的访问令牌将在请求响应中。此方法将为您设置它,因此它主要是供参考,如果需要的话。

$request = $client->doRefreshToken();

获取配置文件列表

$request = $client->listProfiles();
[{
  "profileId":1234567890,
  "countryCode":"US",
  "currencyCode":"USD",
  "dailyBudget":10.00,
  "timezone":"America/Los_Angeles",
  "accountInfo":{
  "marketplaceStringId":"ABC123",
  "sellerStringId":"DEF456"
}]

设置配置文件ID

$client->profileId = "1234567890";

一旦设置了配置文件ID,您就可以开始进行API调用了。

示例API调用

getProfile

通过ID检索单个配置文件。

$client->getProfile("1234567890");
{
  "profileId": 1234567890,
  "countryCode": "US",
  "currencyCode": "USD",
  "dailyBudget": 3.99,
  "timezone": "America/Los_Angeles",
  "accountInfo": {
    "marketplaceStringId": "ABC123",
    "sellerStringId": "DEF456"
  }
}

updateProfiles

更新一个或多个配置文件。广告商使用他们的profileIds进行标识。

$client->updateProfiles(
   array(
       array(
           "profileId" => $client->profileId,
           "dailyBudget" => 3.99),
       array(
           "profileId" => 11223344,
           "dailyBudget" => 6.00)));
[
  {
    "code": "SUCCESS",
    "profileId": 1234567890
  },
  {
    "code": "NOT_FOUND",
    "description": "Profile with id 11223344 was not found for this advertiser.",
    "profileId": 0
  }
]

listCampaigns(SponsoredProducts)

根据可选标准检索满足条件的活动列表。

$client->listSponsoredProductsCampaigns(array("campaignIdFilter" => ['include' => ["ENABLED", "PAUSED"]]));
{
  "totalResults": 0,
  "campaigns": [
    {
      "portfolioId": "string",
      "endDate": "2019-08-24",
      "campaignId": "string",
      "name": "string",
      "targetingType": "AUTO",
      "state": "ENABLED",
      "dynamicBidding": {
        "placementBidding": [
          {
            "percentage": 900,
            "placement": "PLACEMENT_TOP"
          }
        ],
        "strategy": "LEGACY_FOR_SALES"
      },
      "startDate": "2019-08-24",
      "budget": {
        "budgetType": "DAILY",
        "budget": 0,
        "effectiveBudget": 0
      },
      "tags": {
        "property1": "string",
        "property2": "string"
      },
      "extendedData": {
        "lastUpdateDateTime": "2019-08-24T14:15:22Z",
        "servingStatus": "CAMPAIGN_STATUS_ENABLED",
        "servingStatusDetails": [
          {
            "name": "CAMPAIGN_STATUS_ENABLED_DETAIL",
            "helpUrl": "string",
            "message": "string"
          }
        ],
        "creationDateTime": "2019-08-24T14:15:22Z"
      }
    }
  ],
  "nextToken": "string"
}

createCampaigns

创建一个或多个活动。成功创建的活动将被分配唯一的campaignId

$client->createSponsoredProductsCampaigns(
   [
    "campaigns" =>[
        [
            "portfolioId" =>"string",
            "endDate" =>"2019-08-24",
            "name" =>"string",
            "targetingType" =>"AUTO",
            "state" =>"ENABLED",
            "dynamicBidding" => [
                "placementBidding" =>[
                    [
                        "percentage" =>900,
                        "placement" =>"PLACEMENT_TOP"
                    ]
                ],
                "strategy" =>"LEGACY_FOR_SALES"
            ],
            "startDate" =>"2019-08-24",
            "budget" => [
                "budgetType" =>"DAILY",
                "budget" =>0
            ],
            "tags" => [
                "property1" =>"string",
                "property2" =>"string"
            ]
        ]
    ]
]);
{
  "campaigns": {
    "success": [
      {
        "campaignId": "string",
        "index": 0,
        "campaign": {
          "portfolioId": "string",
          "endDate": "2019-08-24",
          "campaignId": "string",
          "name": "string",
          "targetingType": "AUTO",
          "state": "ENABLED",
          "dynamicBidding": {
            "placementBidding": [
              {
                "percentage": 900,
                "placement": "PLACEMENT_TOP"
              }
            ],
            "strategy": "LEGACY_FOR_SALES"
          },
          "startDate": "2019-08-24",
          "budget": {
            "budgetType": "DAILY",
            "budget": 0,
            "effectiveBudget": 0
          },
          "tags": {
            "property1": "string",
            "property2": "string"
          },
          "extendedData": {
            "lastUpdateDateTime": "2019-08-24T14:15:22Z",
            "servingStatus": "CAMPAIGN_STATUS_ENABLED",
            "servingStatusDetails": [
              {
                "name": "CAMPAIGN_STATUS_ENABLED_DETAIL",
                "helpUrl": "string",
                "message": "string"
              }
            ],
            "creationDateTime": "2019-08-24T14:15:22Z"
          }
        }
      }
    ],
    "error": [
      {
        "index": 0,
        "errors": [
          {
            "errorType": "string",
            "errorValue": {
              "entityStateError": {
                "reason": "INVALID_TARGET_STATE",
                "marketplace": "US",
                "entityType": "CAMPAIGN",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "missingValueError": {
                "reason": "MISSING_VALUE",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "dateError": {
                "reason": "INVALID_DATE",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "biddingError": {
                "reason": "BID_GT_BUDGET",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "upperLimit": "string",
                "lowerLimit": "string",
                "message": "string"
              },
              "duplicateValueError": {
                "reason": "DUPLICATE_VALUE",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "rangeError": {
                "reason": "TOO_LOW",
                "marketplace": "US",
                "allowed": [
                  "string"
                ],
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "upperLimit": "string",
                "lowerLimit": "string",
                "message": "string"
              },
              "parentEntityError": {
                "reason": "PARENT_ENTITY_DOES_NOT_TARGET_THESE_MARKETPLACES",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "otherError": {
                "reason": "OTHER_ERROR",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "throttledError": {
                "reason": "THROTTLED",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "entityNotFoundError": {
                "reason": "ENTITY_NOT_FOUND",
                "entityType": "CAMPAIGN",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "entityId": "string",
                "message": "string"
              },
              "malformedValueError": {
                "reason": "FORBIDDEN_CHARS",
                "fragment": "string",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "budgetError": {
                "reason": "BUDGET_TOO_LOW",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "upperLimit": "string",
                "lowerLimit": "string",
                "message": "string"
              },
              "currencyError": {
                "reason": "PREFERRED_CURRENCY_NOT_SET",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "billingError": {
                "reason": "ADVERTISER_SUSPENDED",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "entityQuotaError": {
                "reason": "QUOTA_EXCEEDED",
                "quotaScope": "ACCOUNT",
                "entityType": "CAMPAIGN",
                "quota": "string",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "internalServerError": {
                "reason": "INTERNAL_ERROR",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              }
            }
          }
        ]
      }
    ]
  }
}

updateCampaigns

更新一个或多个活动。活动通过其campaignId进行识别。

$client->updateSponsoredProductsCampaigns(
  [
    "campaigns" =>[
        [
            "portfolioId" =>"string",
            "endDate" =>"2019-08-24",
            "campaignId" =>"string",
            "name" =>"string",
            "targetingType" =>"AUTO",
            "state" =>"ENABLED",
            "dynamicBidding" => [
                "placementBidding" =>[
                    [
                        "percentage" =>900,
                        "placement" =>"PLACEMENT_TOP"
                    ]
                ],
                "strategy" =>"LEGACY_FOR_SALES"
            ],
            "startDate" =>"2019-08-24",
            "budget" => [
                "budgetType" =>"DAILY",
                "budget" =>0
            ],
            "tags" => [
                "property1" =>"string",
                "property2" =>"string"
            ]
        ]
    ]
] 
  );
{
  "campaigns": {
    "success": [
      {
        "campaignId": "string",
        "index": 0,
        "campaign": {
          "portfolioId": "string",
          "endDate": "2019-08-24",
          "campaignId": "string",
          "name": "string",
          "targetingType": "AUTO",
          "state": "ENABLED",
          "dynamicBidding": {
            "placementBidding": [
              {
                "percentage": 900,
                "placement": "PLACEMENT_TOP"
              }
            ],
            "strategy": "LEGACY_FOR_SALES"
          },
          "startDate": "2019-08-24",
          "budget": {
            "budgetType": "DAILY",
            "budget": 0,
            "effectiveBudget": 0
          },
          "tags": {
            "property1": "string",
            "property2": "string"
          },
          "extendedData": {
            "lastUpdateDateTime": "2019-08-24T14:15:22Z",
            "servingStatus": "CAMPAIGN_STATUS_ENABLED",
            "servingStatusDetails": [
              {
                "name": "CAMPAIGN_STATUS_ENABLED_DETAIL",
                "helpUrl": "string",
                "message": "string"
              }
            ],
            "creationDateTime": "2019-08-24T14:15:22Z"
          }
        }
      }
    ],
    "error": [
      {
        "index": 0,
        "errors": [
          {
            "errorType": "string",
            "errorValue": {
              "entityStateError": {
                "reason": "INVALID_TARGET_STATE",
                "marketplace": "US",
                "entityType": "CAMPAIGN",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "missingValueError": {
                "reason": "MISSING_VALUE",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "dateError": {
                "reason": "INVALID_DATE",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "biddingError": {
                "reason": "BID_GT_BUDGET",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "upperLimit": "string",
                "lowerLimit": "string",
                "message": "string"
              },
              "duplicateValueError": {
                "reason": "DUPLICATE_VALUE",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "rangeError": {
                "reason": "TOO_LOW",
                "marketplace": "US",
                "allowed": [
                  "string"
                ],
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "upperLimit": "string",
                "lowerLimit": "string",
                "message": "string"
              },
              "parentEntityError": {
                "reason": "PARENT_ENTITY_DOES_NOT_TARGET_THESE_MARKETPLACES",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "otherError": {
                "reason": "OTHER_ERROR",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "throttledError": {
                "reason": "THROTTLED",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "entityNotFoundError": {
                "reason": "ENTITY_NOT_FOUND",
                "entityType": "CAMPAIGN",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "entityId": "string",
                "message": "string"
              },
              "malformedValueError": {
                "reason": "FORBIDDEN_CHARS",
                "fragment": "string",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "budgetError": {
                "reason": "BUDGET_TOO_LOW",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "upperLimit": "string",
                "lowerLimit": "string",
                "message": "string"
              },
              "currencyError": {
                "reason": "PREFERRED_CURRENCY_NOT_SET",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "billingError": {
                "reason": "ADVERTISER_SUSPENDED",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "entityQuotaError": {
                "reason": "QUOTA_EXCEEDED",
                "quotaScope": "ACCOUNT",
                "entityType": "CAMPAIGN",
                "quota": "string",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "internalServerError": {
                "reason": "INTERNAL_ERROR",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              }
            }
          }
        ]
      }
    ]
  }
}

archiveCampaign

将活动状态设置为存档。此操作可以通过更新执行,但为了完整性包括在内。

$client->deleteSponsoredProductsCampaigns(
[
    "campaignIdFilter" => [
        "include" =>[
            "string"
        ]
    ]
]
);
{
  "campaigns": {
    "success": [
      {
        "campaignId": "string",
        "index": 0,
        "campaign": {
          "portfolioId": "string",
          "endDate": "2019-08-24",
          "campaignId": "string",
          "name": "string",
          "targetingType": "AUTO",
          "state": "ENABLED",
          "dynamicBidding": {
            "placementBidding": [
              {
                "percentage": 900,
                "placement": "PLACEMENT_TOP"
              }
            ],
            "strategy": "LEGACY_FOR_SALES"
          },
          "startDate": "2019-08-24",
          "budget": {
            "budgetType": "DAILY",
            "budget": 0,
            "effectiveBudget": 0
          },
          "tags": {
            "property1": "string",
            "property2": "string"
          },
          "extendedData": {
            "lastUpdateDateTime": "2019-08-24T14:15:22Z",
            "servingStatus": "CAMPAIGN_STATUS_ENABLED",
            "servingStatusDetails": [
              {
                "name": "CAMPAIGN_STATUS_ENABLED_DETAIL",
                "helpUrl": "string",
                "message": "string"
              }
            ],
            "creationDateTime": "2019-08-24T14:15:22Z"
          }
        }
      }
    ],
    "error": [
      {
        "index": 0,
        "errors": [
          {
            "errorType": "string",
            "errorValue": {
              "entityStateError": {
                "reason": "INVALID_TARGET_STATE",
                "marketplace": "US",
                "entityType": "CAMPAIGN",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "missingValueError": {
                "reason": "MISSING_VALUE",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "dateError": {
                "reason": "INVALID_DATE",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "biddingError": {
                "reason": "BID_GT_BUDGET",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "upperLimit": "string",
                "lowerLimit": "string",
                "message": "string"
              },
              "duplicateValueError": {
                "reason": "DUPLICATE_VALUE",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "rangeError": {
                "reason": "TOO_LOW",
                "marketplace": "US",
                "allowed": [
                  "string"
                ],
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "upperLimit": "string",
                "lowerLimit": "string",
                "message": "string"
              },
              "parentEntityError": {
                "reason": "PARENT_ENTITY_DOES_NOT_TARGET_THESE_MARKETPLACES",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "otherError": {
                "reason": "OTHER_ERROR",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "throttledError": {
                "reason": "THROTTLED",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "entityNotFoundError": {
                "reason": "ENTITY_NOT_FOUND",
                "entityType": "CAMPAIGN",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "entityId": "string",
                "message": "string"
              },
              "malformedValueError": {
                "reason": "FORBIDDEN_CHARS",
                "fragment": "string",
                "marketplace": "US",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "budgetError": {
                "reason": "BUDGET_TOO_LOW",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "upperLimit": "string",
                "lowerLimit": "string",
                "message": "string"
              },
              "currencyError": {
                "reason": "PREFERRED_CURRENCY_NOT_SET",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "billingError": {
                "reason": "ADVERTISER_SUSPENDED",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "entityQuotaError": {
                "reason": "QUOTA_EXCEEDED",
                "quotaScope": "ACCOUNT",
                "entityType": "CAMPAIGN",
                "quota": "string",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              },
              "internalServerError": {
                "reason": "INTERNAL_ERROR",
                "cause": {
                  "location": "string",
                  "trigger": "string"
                },
                "message": "string"
              }
            }
          }
        ]
      }
    ]
  }
}

listAdGroups

根据可选标准检索满足条件的广告组列表。

$client->listAdGroups(array("stateFilter" => "enabled"));
[
  {
    "adGroupId": 262960563101486,
    "name": "AdGroup One",
    "campaignId": 181483024866689,
    "defaultBid": 1.0,
    "state": "enabled"
  },
  {
    "adGroupId": 52169162825843,
    "name": "AdGroup Two",
    "campaignId": 250040549047739,
    "defaultBid": 2.0,
    "state": "enabled"
  }
]

getAdGroup

通过ID检索广告组。请注意,此调用返回广告组的最少字段集,但比getAdGroupEx更高效。

$client->getAdGroup(262960563101486);
{
  "adGroupId": 262960563101486,
  "name": "AdGroup One",
  "campaignId": 181483024866689,
  "defaultBid": 1.0,
  "state": "enabled"
}

createAdGroups

创建一个或多个广告组。成功创建的广告组将被分配唯一的adGroupId

$client->createAdGroups(
    array(
        array(
            "campaignId" => 250040549047739,
            "name" => "New AdGroup One",
            "state" => "enabled",
            "defaultBid" => 2.0),
        array(
            "campaignId" => 59836775211065,
            "name" => "New AdGroup Two",
            "state" => "enabled",
            "defaultBid" => 5.0)));
[
  {
    "code": "SUCCESS",
    "adGroupId": 117483076163518
  },
  {
    "code": "SUCCESS",
    "adGroupId": 123431426718271
  }
]

updateAdGroups

更新一个或多个广告组。广告组通过其adGroupId进行识别。

$client->updateAdGroups(
    array(
        array(
            "adGroupId" => 117483076163518,
            "state" => "enabled",
            "defaultBid" => 20.0),
        array(
            "adGroupId" => 123431426718271,
            "state" => "enabled",
            "defaultBid" => 15.0)));
[
  {
    "code": "SUCCESS",
    "adGroupId": 117483076163518
  },
  {
    "code": "SUCCESS",
    "adGroupId": 123431426718271
  }
]

archiveAdGroup

将广告组状态设置为存档。此操作可以通过更新执行,但为了完整性包括在内。

$client->archiveAdGroup(117483076163518);
{
  "code": "SUCCESS",
  "adGroupId": 117483076163518
}

listBiddableKeywords

根据可选标准检索满足条件的关键词列表。

$client->listBiddableKeywords(array("stateFilter" => "enabled"));
[
  {
    "keywordId": 174140697976855,
    "adGroupId": 52169162825843,
    "campaignId": 250040549047739,
    "keywordText": "KeywordOne",
    "matchType": "exact",
    "state": "enabled"
  },
  {
    "keywordId": 118195812188994,
    "adGroupId": 52169162825843,
    "campaignId": 250040549047739,
    "keywordText": "KeywordTwo",
    "matchType": "exact",
    "state": "enabled"
  }
]

getBiddableKeyword

通过ID检索关键词。请注意,此调用返回关键词的最少字段集,但比getBiddableKeywordEx更高效。

$client->getBiddableKeyword(174140697976855);
{
  "keywordId": 174140697976855,
  "adGroupId": 52169162825843,
  "campaignId": 250040549047739,
  "keywordText": "KeywordOne",
  "matchType": "exact",
  "state": "enabled"
}

createBiddableKeywords

创建一个或多个关键词。成功创建的关键词将被分配唯一的keywordId

$client->createBiddableKeywords(
    array(
        array(
            "campaignId" => 250040549047739,
            "adGroupId" => 52169162825843,
            "keywordText" => "AnotherKeyword",
            "matchType" => "exact",
            "state" => "enabled"),
        array(
            "campaignId" => 250040549047739,
            "adGroupId" => 52169162825843,
            "keywordText" => "YetAnotherKeyword",
            "matchType" => "exact",
            "state" => "enabled")));
[
  {
    "code": "SUCCESS",
    "keywordId": 112210768353976
  },
  {
    "code": "SUCCESS",
    "keywordId": 249490346605943
  }
]

updateBiddableKeywords

更新一个或多个关键词。关键词通过其keywordId进行识别。

$client->updateBiddableKeywords(
       array(
           array(
               "keywordId" => 112210768353976,
               "bid" => 100.0,
               "state" => "archived"),
           array(
               "keywordId" => 249490346605943,
               "bid" => 50.0,
               "state" => "archived")));
[
  {
    "code": "SUCCESS",
    "keywordId": 112210768353976
  },
  {
    "code": "SUCCESS",
    "keywordId": 249490346605943
  }
]

archiveBiddableKeyword

将关键词状态设置为存档。此操作可以通过更新执行,但为了完整性包括在内。

$client->archiveBiddableKeyword(112210768353976);
{
  "code": "200",
  "requestId": "0TR95PJD6Z16FFCZDXD0"
}

listNegativeKeywords

根据可选标准检索满足条件的否定关键词列表。

$client->listNegativeKeywords(array("stateFilter" => "enabled"));
[
  {
    "keywordId": 281218602770639,
    "adGroupId": 52169162825843,
    "campaignId": 250040549047739,
    "keywordText": "KeywordOne",
    "matchType": "negativeExact",
    "state": "enabled"
  },
  {
    "keywordId": 280875877064090,
    "adGroupId": 262960563101486,
    "campaignId": 181483024866689,
    "keywordText": "KeywordTwo",
    "matchType": "negativeExact",
    "state": "enabled"
  }
]

getNegativeKeyword

通过ID检索否定关键词。请注意,此调用返回关键词的最少字段集,但比getNegativeKeywordEx更高效。

$client->getNegativeKeyword(281218602770639);
{
  "keywordId": 281218602770639,
  "adGroupId": 52169162825843,
  "campaignId": 250040549047739,
  "keywordText": "KeywordOne",
  "matchType": "negativeExact",
  "state": "enabled"
}

createNegativeKeywords

创建一个或多个否定关键词。成功创建的关键词将被分配唯一的keywordIds。

$client->createNegativeKeywords(
    array(
        array(
            "campaignId" => 250040549047739,
            "adGroupId" => 52169162825843,
            "keywordText" => "AnotherKeyword",
            "matchType" => "negativeExact",
            "state" => "enabled"),
        array(
            "campaignId" => 181483024866689,
            "adGroupId" => 262960563101486,
            "keywordText" => "YetAnotherKeyword",
            "matchType" => "negativeExact",
            "state" => "enabled")));
[
  {
    "code": "SUCCESS",
    "keywordId": 61857817062026
  },
  {
    "code": "SUCCESS",
    "keywordId": 147623067066967
  }
]

updateNegativeKeywords

更新一个或多个否定关键词。关键词通过其keywordId进行识别。

$client->updateNegativeKeywords(
       array(
           array(
               "keywordId" => 61857817062026,
               "state" => "enabled",
               "bid" => 15.0),
           array(
               "keywordId" => 61857817062026,
               "state" => "enabled",
               "bid" => 20.0)));
[
  {
    "code": "SUCCESS",
    "keywordId": 61857817062026
  },
  {
    "code": "INVALID_ARGUMENT",
    "description": "Entity with id 61857817062026 already specified in this update operation."
  }
]

archiveNegativeKeyword

将否定关键词状态设置为存档。此操作可以通过更新状态执行,但为了完整性包括在内。

$client->archiveNegativeKeyword(61857817062026);
{
  "code": "SUCCESS",
  "keywordId": 61857817062026
}

listCampaignNegativeKeywords

根据可选标准检索满足条件的否定活动关键词列表。

$client->listCampaignNegativeKeywords(array("matchTypeFilter" => "negativeExact"));
[
  {
    "keywordId": 131747786239884,
    "adGroupId": null,
    "campaignId": 181483024866689,
    "keywordText": "Negative Keyword",
    "matchType": "negativeExact",
    "state": "enabled"
  },
  {
    "keywordId": 197201372210821,
    "adGroupId": null,
    "campaignId": 181483024866689,
    "keywordText": "My Negative Keyword",
    "matchType": "negativeExact",
    "state": "enabled"
  }
]

getCampaignNegativeKeyword

通过ID检索活动否定关键词。请注意,此调用返回关键词的最少字段集,但比getCampaignNegativeKeywordEx更高效。

$client->getCampaignNegativeKeyword(197201372210821);
{
  "keywordId": 197201372210821,
  "adGroupId": null,
  "campaignId": 181483024866689,
  "keywordText": "My Negative Keyword",
  "matchType": "negativeExact",
  "state": "enabled"
}

createCampaignNegativeKeywords

创建一个或多个活动否定关键词。成功创建的关键词将被分配唯一的keywordId

$client->createCampaignNegativeKeywords(
       array(
           array(
               "campaignId" => 181483024866689,
               "keywordText" => "Negative Keyword One",
               "matchType" => "negativeExact",
               "state" => "enabled"),
           array(
               "campaignId" => 181483024866689,
               "keywordText" => "Negative Keyword Two",
               "matchType" => "negativeExact",
               "state" => "enabled")));
[
  {
    "code": "SUCCESS",
    "keywordId": 196797670902082
  },
  {
    "code": "SUCCESS",
    "keywordId": 186203479904657
  }
]

updateCampaignNegativeKeywords

更新一个或多个活动否定关键词。关键词通过其keywordId进行识别。

活动否定关键词目前只能被删除。

removeCampaignNegativeKeyword

将活动否定关键词状态设置为已删除。此操作可以通过更新状态执行,但为了完整性包括在内。

$client->removeCampaignNegativeKeyword(186203479904657);
{
  "code": "SUCCESS",
  "keywordId": 186203479904657
}

listProductAds

根据可选标准检索满足条件的商品广告列表。

$client->listProductAds(array("stateFilter" => "enabled"));
[
  {
    "adId": 247309761200483,
    "adGroupId": 262960563101486,
    "campaignId": 181483024866689,
    "sku": "TEST001",
    "state": "enabled"
  }
]

getProductAd

通过ID检索商品广告。请注意,此调用返回商品广告的最少字段集,但比getProductAdEx更高效。

$client->getProductAd(247309761200483);
{
  "adId": 247309761200483,
  "adGroupId": 262960563101486,
  "campaignId": 181483024866689,
  "sku": "TEST001",
  "state": "enabled"
}

createProductAds

创建一个或多个商品广告。成功创建的商品广告将被分配唯一的adId

$client->createProductAds(
    array(
        array(
            "campaignId" => 181483024866689,
            "adGroupId" => 262960563101486,
            "sku" => "TEST002",
            "state" => "enabled"),
        array(
            "campaignId" => 181483024866689,
            "adGroupId" => 262960563101486,
            "sku" => "TEST003",
            "state" => "enabled")));
[
  {
    "code": "SUCCESS",
    "adId": 239870616623537
  },
  {
    "code": "SUCCESS",
    "adId": 191456410590622
  }
]

updateProductAds

更新一个或多个商品广告。商品广告通过其adId进行识别。

$client->updateProductAds(
    array(
        array(
            "adId" => 239870616623537,
            "state" => "archived"),
        array(
            "adId" => 191456410590622,
            "state" => "archived")));
[
  {
    "code": "SUCCESS",
    "adId": 239870616623537
  },
  {
    "code": "SUCCESS",
    "adId": 191456410590622
  }
]

archiveProductAd

将商品广告状态设置为存档。此操作可以通过更新执行,但为了完整性包括在内。

$client->archiveProductAd(239870616623537);
{
  "code": "SUCCESS",
  "adId": 239870616623537
}

requestSnapshot

请求单个类型的所有实体的快照报告。

$client->requestSnapshot(
    "campaigns",
    array("stateFilter" => "enabled,paused,archived",
          "campaignType" => "sponsoredProducts"));
{
  "snapshotId": "amzn1.clicksAPI.v1.p1.573A0477.ec41773a-1659-4013-8eb9-fa18c87ef5df",
  "recordType": "campaign",
  "status": "IN_PROGRESS"
}

getSnapshot

检索先前请求的报告。

$client->getSnapshot("amzn1.clicksAPI.v1.p1.573A0477.ec41773a-1659-4013-8eb9-fa18c87ef5df");
[
  {
    "campaignId": 181483024866689,
    "name": "Campaign One",
    "campaignType": "sponsoredProducts",
    "targetingType": "manual",
    "dailyBudget": 5.0,
    "startDate": "20160330",
    "state": "archived"
  },
  {
    "campaignId": 59836775211065,
    "name": "Campaign Two",
    "campaignType": "sponsoredProducts",
    "targetingType": "manual",
    "dailyBudget": 10.99,
    "startDate": "20160330",
    "state": "archived"
  },
  {
    "campaignId": 254238342004647,
    "name": "Campaign Three",
    "campaignType": "sponsoredProducts",
    "targetingType": "manual",
    "dailyBudget": 99.99,
    "startDate": "20160510",
    "state": "enabled"
  }
]

requestReport

请求单个类型的所有实体的自定义性能报告,这些实体有性能数据可供报告。枚举:sb,sd,sp

$client->requestReport(
    "campaigns",
    array("reportDate" => "20160515",
          "campaignType" => "sp",
          "metrics" => "impressions,clicks,cost"));
{
  "reportId": "amzn1.clicksAPI.v1.m1.573A0808.32908def-66a1-4ce2-8f12-780dc4ae1d43",
  "recordType": "campaign",
  "status": "IN_PROGRESS",
  "statusDetails": "Report is submitted"
}

getReport

检索先前请求的报告。

$client->getReport("amzn1.clicksAPI.v1.m1.573A0808.32908def-66a1-4ce2-8f12-780dc4ae1d43");

沙箱将返回虚拟数据。

[
  {
    "cost": 647.75,
    "campaignId": 230751293360275,
    "clicks": 2591,
    "impressions": 58288
  },
  {
    "cost": 619.5,
    "campaignId": 52110033002744,
    "clicks": 2478,
    "impressions": 68408
  },
  {
    "cost": 151.91,
    "campaignId": 140739567440917,
    "clicks": 633,
    "impressions": 17343
  },
  {
    "cost": 143.46,
    "campaignId": 79132327246328,
    "clicks": 797,
    "impressions": 48903
  }
]

getAdGroupBidRecommendations

请求指定广告组的出价建议。

$client->getAdGroupBidRecommendations(1234509876);
{
  "adGroupId": 1234509876,
  "suggestedBid": {
    "rangeEnd": 2.16,
    "rangeStart": 0.67,
    "suggested": 1.67
  }
}

getKeywordBidRecommendations

请求指定关键词的出价建议。

$client->getKeywordBidRecommendations(85243141758914);
{
  "keywordId": 85243141758914,
  "adGroupId": 252673310548066,
  "suggestedBid": {
    "rangeEnd": 3.18,
    "rangeStart": 0.35,
    "suggested": 2.97
  }
}

bulkGetKeywordBidRecommendations

请求最多100个关键词的出价建议列表。

$client->bulkGetKeywordBidRecommendations(
    242783265349805,
    array(
        array("keyword" => "testKeywordOne",
              "matchType" => "exact"),
        array("keyword" => "testKeywordTwo",
              "matchType" => "exact")
    ));
{
  "adGroupId": 242783265349805,
  "recommendations": [
    {
      "code": "SUCCESS",
      "keyword": "testKeywordOne",
      "matchType": "exact",
      "suggestedBid": {
        "rangeEnd": 2.67,
        "rangeStart": 0.38,
        "suggested": 2.07
      }
    },
    {
      "code": "SUCCESS",
      "keyword": "testKeywordTwo",
      "matchType": "exact",
      "suggestedBid": {
        "rangeEnd": 3.19,
        "rangeStart": 0.79,
        "suggested": 3.03
      }
    }
  ]
}

getAdGroupKeywordSuggestions

请求指定广告组的出价建议。

$client->getAdGroupKeywordSuggestions(
    array("adGroupId" => 1234567890,
          "maxNumSuggestions" => 2,
          "adStateFilter" => "enabled"));
{
  "adGroupId": 1234567890,
  "suggestedKeywords": [
    {
      "keywordText": "keyword PRODUCT_AD_A 1",
      "matchType": "broad"
    },
    {
      "keywordText": "keyword PRODUCT_AD_B 1",
      "matchType": "broad"
    }
  ]
}

getAdGroupKeywordSuggestionsEx

请求指定广告组的扩展版出价建议,可以返回返回关键词的出价建议。

$client->getAdGroupKeywordSuggestionsEx(
    array("adGroupId" => 1234567890,
          "maxNumSuggestions" => 2,
          "suggestBids" => "yes",
          "adStateFilter" => "enabled"));
[
  {
    "adGroupId": 1234567890,
    "campaignId": 0987654321,
    "keywordText": "keyword TESTASINXX 1",
    "matchType": "broad",
    "state": "enabled",
    "bid": 1.84
  },
  {
    "adGroupId": 1234567890,
    "campaignId": 0987654321,
    "keywordText": "keyword TESTASINXX 2",
    "matchType": "broad",
    "state": "enabled",
    "bid": 1.07
  }
]

getAsinKeywordSuggestions

请求指定asin的关键词建议。

$client->getAsinKeywordSuggestions(
    array("asin" => "B00IJSNPM0",
          "maxNumSuggestions" => 2));
[
  {
    "keywordText": "keyword B00IJSNPM0 1",
    "matchType": "broad"
  },
  {
    "keywordText": "keyword B00IJSNPM0 2",
    "matchType": "broad"
  }
]

bulkGetAsinKeywordSuggestions

请求asin列表的关键词建议。

$client->bulkGetAsinKeywordSuggestions(
    array("asins" => array(
              "B00IJSNPM0",
              "B00IJSO1NM"),
          "maxNumSuggestions" => 2));
[
  {
    "keywordText": "keyword B00IJSNPM0 1",
    "matchType": "broad"
  },
  {
    "keywordText": "keyword B00IJSO1NM 1",
    "matchType": "broad"
  }
]