{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "mws-feeds:SubmitFeed", "mws-reports:RequestReport", "mws-reports:GetReport", "mws-reports:GetReportList", "mws-orders:ListOrders", "mws-orders:ListOrderItems", "mws-products:GetMatchingProduct", "mws-products:GetCompetitivePricingForSKU", "mws-products:GetCompetitivePricingForASIN", "mws-products:GetLowestOfferListingsForSKU", "mws-products:GetLowestOfferListingsForASIN", "mws-products:GetMyPriceForSKU", "mws-products:GetMyPriceForASIN", "mws-products:GetProductCategoriesForSKU", "mws-products:GetProductCategoriesForASIN" ], "Resource": [ "*" ] } ] }
//加载AWS SDK for PHP v3 require 'vendor/autoload.php';
use Aws\Credentials\Credentials; use Aws\Sts\StsClient;
//获取IAM角色凭据 $sts = new StsClient([ 'region' => 'us-west-2', 'version' => '2011-06-15' ]);
$credentials = $sts->assumeRole([ 'RoleArn' => 'arn:aws:iam::ACCOUNT-ID-WITHOUT-HYPHENS:role/ROLE-NAME', 'RoleSessionName' => 'AmazonMWS', ]);
//设置MWS客户端 $config = [ 'MerchantId' => 'YOUR_MERCHANT_ID', 'MarketplaceId' => 'YOUR_MARKETPLACE_ID', 'AWSAccessKeyId' => $credentials->get('AccessKeyId'), 'SellerId' => 'YOUR_SELLER_ID', 'SecretKey' => $credentials->get('SecretAccessKey'), 'ServiceURL' => 'https://mws.amazonservices.com', 'MWSAuthToken' => 'YOUR_MWS_AUTH_TOKEN', ];
$mws = new MarketplaceWebService_Client( $config['AWSAccessKeyId'], $config['SecretKey'], $config['AppName'],