PHP code example of lai3221 / amzn_adv_api_php
1. Go to this page and download the library: Download lai3221/amzn_adv_api_php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lai3221 / amzn_adv_api_php example snippets
namespace AmazonAdvertisingApi;
LIENT_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();
$client->profileId = "1234567890";
$client->getProfile("1234567890");
$client->updateProfiles(
array(
array(
"profileId" => $client->profileId,
"dailyBudget" => 3.99),
array(
"profileId" => 11223344,
"dailyBudget" => 6.00)));
$client->listSponsoredProductsCampaigns(array("campaignIdFilter" => ['
$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"
]
]
]
]);
$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"
]
]
]
]
);
$client->deleteSponsoredProductsCampaigns(
[
"campaignIdFilter" => [
"
$client->listAdGroups(array("stateFilter" => "enabled"));
$client->getAdGroup(262960563101486);
$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)));
$client->updateAdGroups(
array(
array(
"adGroupId" => 117483076163518,
"state" => "enabled",
"defaultBid" => 20.0),
array(
"adGroupId" => 123431426718271,
"state" => "enabled",
"defaultBid" => 15.0)));
$client->archiveAdGroup(117483076163518);
$client->listBiddableKeywords(array("stateFilter" => "enabled"));
$client->getBiddableKeyword(174140697976855);
$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")));
$client->updateBiddableKeywords(
array(
array(
"keywordId" => 112210768353976,
"bid" => 100.0,
"state" => "archived"),
array(
"keywordId" => 249490346605943,
"bid" => 50.0,
"state" => "archived")));
$client->archiveBiddableKeyword(112210768353976);
$client->listNegativeKeywords(array("stateFilter" => "enabled"));
$client->getNegativeKeyword(281218602770639);
$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")));
$client->updateNegativeKeywords(
array(
array(
"keywordId" => 61857817062026,
"state" => "enabled",
"bid" => 15.0),
array(
"keywordId" => 61857817062026,
"state" => "enabled",
"bid" => 20.0)));
$client->archiveNegativeKeyword(61857817062026);
$client->listCampaignNegativeKeywords(array("matchTypeFilter" => "negativeExact"));
$client->getCampaignNegativeKeyword(197201372210821);
$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")));
$client->removeCampaignNegativeKeyword(186203479904657);
$client->listProductAds(array("stateFilter" => "enabled"));
$client->getProductAd(247309761200483);
$client->createProductAds(
array(
array(
"campaignId" => 181483024866689,
"adGroupId" => 262960563101486,
"sku" => "TEST002",
"state" => "enabled"),
array(
"campaignId" => 181483024866689,
"adGroupId" => 262960563101486,
"sku" => "TEST003",
"state" => "enabled")));
$client->updateProductAds(
array(
array(
"adId" => 239870616623537,
"state" => "archived"),
array(
"adId" => 191456410590622,
"state" => "archived")));
$client->archiveProductAd(239870616623537);
$client->requestSnapshot(
"campaigns",
array("stateFilter" => "enabled,paused,archived",
"campaignType" => "sponsoredProducts"));
$client->getSnapshot("amzn1.clicksAPI.v1.p1.573A0477.ec41773a-1659-4013-8eb9-fa18c87ef5df");
$client->requestReport(
"campaigns",
array("reportDate" => "20160515",
"campaignType" => "sp",
"metrics" => "impressions,clicks,cost"));
$client->getReport("amzn1.clicksAPI.v1.m1.573A0808.32908def-66a1-4ce2-8f12-780dc4ae1d43");
$client->getAdGroupBidRecommendations(1234509876);
$client->getKeywordBidRecommendations(85243141758914);
$client->bulkGetKeywordBidRecommendations(
242783265349805,
array(
array("keyword" => "testKeywordOne",
"matchType" => "exact"),
array("keyword" => "testKeywordTwo",
"matchType" => "exact")
));
$client->getAdGroupKeywordSuggestions(
array("adGroupId" => 1234567890,
"maxNumSuggestions" => 2,
"adStateFilter" => "enabled"));
$client->getAdGroupKeywordSuggestionsEx(
array("adGroupId" => 1234567890,
"maxNumSuggestions" => 2,
"suggestBids" => "yes",
"adStateFilter" => "enabled"));
$client->getAsinKeywordSuggestions(
array("asin" => "B00IJSNPM0",
"maxNumSuggestions" => 2));
$client->bulkGetAsinKeywordSuggestions(
array("asins" => array(
"B00IJSNPM0",
"B00IJSO1NM"),
"maxNumSuggestions" => 2));