我正在尝试将cart函数添加到https://github.com/Exeu/Amazon-ECS-PHP-Library提供的AmazonECS类中
该项目的主类是https://github.com/Exeu/Amazon-ECS-PHP-Library/blob/master/lib/AmazonECS.class.php
它目前支持ItemLookup和ItemSearch,但没有CartCreate、CartClear、CartAdd、CartGet和CartModify。
亚马逊关于这些API调用的文档可以在这个页面http://docs.aws.amazon.com/AWSECommerceService/2011-08-01/DG/CartCreate.html上找到。
这是我尝试过的一种方法,但没有奏效。
/**
* execute CartCreate request
*
* @param string $asin, $associateTag
*
* @return array|object return type depends on setting
*
* @see returnType()
*/
public function cartCreate($asin, $associateTag)
{
$params = $this->buildRequestParams('CartCreate', array(
array('Item.1.ASIN' => $asin, 'Item.1.Quantity' => 1),
'AssociateTag' => $associateTag,
));
return $this->returnData($this->performSoapRequest("CartCreate", $params));
}有人知道我做错了什么吗?我从调用中得到的错误消息是
string(79) "Your request is missing required parameters. Required parameters include Items."发布于 2013-12-16 10:09:53
对于任何还在寻找答案的人,我有这个解决方案给你。下面是我的购物车函数:
public function CartCreate($OfferListingId)
{
$params = $this->buildRequestParams('CartCreate', array(
'Items' => array(
'Item' => array(
//You can also use 'ASIN' here
'OfferListingId' => $OfferListingId,
'Quantity' => 1,
)
)
));
return $this->returnData(
$this->performSoapRequest("CartCreate", $params)
);
}您发送的参数应构造为关联的数组。
此外,如果您遇到无法将带有ASIN的商品添加到购物车的错误,请记住将国家代码添加到请求中,因为默认值是美国,例如,在我的案例中,我需要来自英国的商品。这是我如何处理我的请求:
$cart = $this->ecs->country('UK')->ResponseGroup('Cart')->CartCreate($OfferListingId);发布于 2013-03-11 21:17:31
我可能错了,但我不认为你的Item.1.ID应该是另一个数组的一部分。试着这样做:
$params = $this->buildRequestParams('CartCreate', array(
'Item.1.ASIN' => $asin,
'Item.1.Quantity' => 1,
'AssociateTag' => $associateTag,
));https://stackoverflow.com/questions/15232253
复制相似问题