1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

LaravelでAmazon MWS APIを使用し注文情報を取得する

Posted at

事前準備

Amazon MWSのアカウント:申請してから1ヶ月くらいかかります。

ファイルをダウンロードしてきます

Composerは使用できないので、以下より注文用のファイルをダウンロードします。
https://developer.amazonservices.jp/phpclients

Laravelに追加

今回は appp/Librariesというディレクトリを追加し、
そこに上記でダウンロードした MarketplaceWebServiceOrders をフォルダごと追加します。

composer.json に設定を追加

以下のようにします。

composer.json
"autoload": {
  "classmap": [
    "app/Libraries/Amazon/MarketplaceWebServiceOrders/Client.php"
  ],
  // その他設定
}

そして composer dump-autoload を実行

PHP5.6以降は以下でひっかかるので条件追加

Client.php

if ( (float)phpversion() < 5.6 ) {
  iconv_set_encoding('output_encoding', 'UTF-8');
  iconv_set_encoding('input_encoding', 'UTF-8');
  iconv_set_encoding('internal_encoding', 'UTF-8');
}

これで使えるようになるはず。


use MarketplaceWebServiceProducts_Client;

// Japan
$serviceUrl = "https://mws.amazonservices.jp/Orders/2013-09-01";

$config = array (
    'ServiceURL' => $serviceUrl,
    'ProxyHost' => null,
    'ProxyPort' => -1,
    'ProxyUsername' => null,
    'ProxyPassword' => null,
    'MaxErrorRetry' => 3,
);

// 以下は申請が承認されるともらえます
$service = new MarketplaceWebServiceProducts_Client(
    AWS_ACCESS_KEY_ID,
    AWS_SECRET_ACCESS_KEY,
    APPLICATION_NAME,
    APPLICATION_VERSION,
    $config);

// getServiceStatus
$getServiceStatus = $service->getServiceStatus(null);
var_dump($getServiceStatus->GetServiceStatusResult);
echo $getServiceStatus->GetServiceStatusResult->Status; // GREENなど

// 注文情報の取得
$parameters = [
    'SellerId'      => $sellerId,
    'AmazonOrderId' => $orderId
];
$getOrder = $service->getOrder($parameters);

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?