php - 亚马逊 MWS - 使用 GetMyFeesEstimate (PHP/Laravel)
问题描述
我将以下包用于 Amazon MWS 以用于 Laravel 项目 ( https://packagist.org/packages/mcs/amazon-mws )。它运行良好,但缺少我需要的一种关键方法,GetMyFeesEstimate。
现在,我尝试自己扩展代码:在 MWSEndPoint.php 中,我放了:
'GetMyFeesEstimate'=> [
'method' => 'POST',
'action' => 'GetMyFeesEstimate',
'path' => '/Products/2011-10-01',
'date' => '2011-10-01'
],
在 MWSClient.php 中,我尝试了以下方法:
public function GetMyFeesEstimate($type, $idvalue, $price, $fba)
{
$array = [
'MarketplaceId' => $this->config['Marketplace_Id']
];
$feesEstimateRequest = [
'IdType' => $type,
'IdValue' => $idvalue,
'PriceToEstimateFees' => array('ListingPrice'=>array('Amount',floatval($price))),
'Identifier' => null,
'IsAmazonFulfilled' => $fba
];
$array['FeesEstimateRequestList'] = array($feesEstimateRequest);
$response = $this->request(
'GetMyFeesEstimate',
$array
);
dd($response);
}
但是,我收到以下错误,我不确定哪里出错了:“我们计算的请求签名与您提供的签名不匹配。请检查您的 AWS 秘密访问密钥和签名方法。请参阅服务文档了解详情。”
我已经玩了几个小时,广泛查看了文档: http: //docs.developer.amazonservices.com/en_US/products/Products_GetMyFeesEstimate.html http://docs.developer.amazonservices.com/ en_US/products/Products_Datatypes.html#FeesEstimateRequest
...但没有成功。请问有人可以帮我吗?
解决方案
好的,我又查看了文档并想出了这个(它有效):
public function GetMyFeesEstimate($idtype, $idvalue, $price, $currency, $fba)
{
$query = [
'MarketplaceId' => $this->config['Marketplace_Id']
];
$query['FeesEstimateRequestList.FeesEstimateRequest.1.MarketplaceId'] = $this->config['Marketplace_Id'];
$query['FeesEstimateRequestList.FeesEstimateRequest.1.IdType'] = $idtype;
$query['FeesEstimateRequestList.FeesEstimateRequest.1.IdValue'] = $idvalue;
$query['FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.Amount'] = floatval($price);
$query['FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.CurrencyCode'] = $currency;
$query['FeesEstimateRequestList.FeesEstimateRequest.1.Identifier'] = gmdate(self::DATE_FORMAT, time());
$query['FeesEstimateRequestList.FeesEstimateRequest.1.IsAmazonFulfilled'] = $fba;
$response = $this->request(
'GetMyFeesEstimate',
$query
);
return $response;
}
推荐阅读
- java - 你能摆脱这些 if 并让这段代码更面向对象吗
- java - 打印代码不带注释
- javascript - 使用 css 模块在反应应用程序中将类应用于 d3 图表
- android - RxJava2 - 向上游传输下游错误
- python - Google App Engine 标准环境可以连接到 GRPC 服务吗?
- java - 调用 ArrayList
从 main 并给出一个整数数组作为参数 - python - 如何与 Spark 并行处理相同的图像以避免不必要的复制?
- sql-server - SQL AG 辅助作为第二组的主
- freeradius - 从 Source 安装时,CentOS 7 上未安装 freeRadius 服务
- c++ - boost::bimap 对内射函数来说是不是矫枉过正?