3

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呼び出しに関するAmazonのドキュメントは、このページ http://docs.aws.amazon.com/AWSECommerceService/2011-08-01/DG/CartCreate.htmlにあります。

これが私が試したがうまくいかなかったことの1つです。

/**
* 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."
4

2 に答える 2

2

まだこれに対する答えを探している人のために、私はあなたのためにこの解決策を持っています。以下は私のカート機能です:

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-12-16T02:09:53.277 に答える
0

私は間違っているかもしれませんが、あなたのItem.1.IDは別の配列の一部であるべきではないと思います。代わりにこれを試してください:

$params = $this->buildRequestParams('CartCreate', array(
  'Item.1.ASIN' => $asin, 
  'Item.1.Quantity' => 1,
  'AssociateTag' => $associateTag,
));
于 2013-03-11T13:17:31.440 に答える