【Rinker】401:AmazonAPIのステータスエラー【対策方法】

Rinker:401:AmazonAPIのステータスエラー

ブログに掲載したい商品のリンクをワンストップで作成できる、WordPressプラグインのRinker(リンカー)
今回の記事ではこの「Rinker」で発生する、401:AmazonAPIのステータスエラーへの対策方法を解説します。

401:AmazonAPIのステータスエラー

この記事で対策するRinkerのエラーは、Rinkerで「Amazonから商品検索」を行った際に表示されます。

401:AmazonAPIのステータスエラー

エラー

401:AmazonAPIのステータスエラー: {"message":"The authentication token is invalid or malformed","reason":"InvalidToken","type":"UnauthorizedException"} AmazonAPIのステータスエラー

ステータスエラーの対策方法

401:AmazonAPIのステータスエラーを直すには、まず目的の「yyi_rinker_main.php」をバックアップします。

ステータスエラーの対策方法

yyi_rinker_main.phpをバックアップしたら「直接テキストエディタ」で開くか、下記の手順で「yyi_rinker_main.php」を開きます。

1️⃣プラグイン
2️⃣プラグインファイルエディター
3️⃣編集するプラグインを選択 ⇒ Rinker
4️⃣選択
5️⃣yyi_rinker_main.php

ステータスエラーの対策方法-2

yyi_rinker_main.phpを開いたら「2286行目から2296行目まで」を、

ステータスエラーの対策方法-3

編集前

$curl = curl_init();
$auth_creds = $creator_auth_id . ':' . $creator_secret_key;
$headers = [
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Basic ' . base64_encode($auth_creds),
];

curl_setopt($curl, CURLOPT_URL, 'https://creatorsapi.auth.us-west-2.amazoncognito.com/oauth2/token');
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POSTFIELDS, 'grant_type=client_credentials&scope=creatorsapi/default');
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

下記の文字列に書き換えます。

ステータスエラーの対策方法-4

編集後

$curl = curl_init();
$headers = [
'Content-Type: application/json',
];
$token_payload = json_encode([
'grant_type' => 'client_credentials',
'client_id' => $creator_auth_id,
'client_secret' => $creator_secret_key,
'scope' => 'creatorsapi::default',
]);
curl_setopt($curl, CURLOPT_URL, 'https://api.amazon.co.jp/auth/o2/token');
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POSTFIELDS, $token_payload);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

文字列を書き換えたら、ページ下部の「ファイルを更新」から変更を保存します。

ステータスエラーの対策方法-5

ステータスエラーの対策確認

上記の手順で「yyi_rinker_main.php」を更新したら、Rinkerの「商品リンク追加」を試します。
1️⃣~3️⃣の方法でAmazonから商品情報を取得し、問題なく「商品リンクを追加」が機能すれば完了です。

1️⃣Amazonから商品検索
2️⃣検索したい商品「任意の文字列」を入力
3️⃣検索

ステータスエラーの対策確認

Creators API優先の設定方法

ちなみにこの記事と関連する「Creators API優先の設定方法」は、別記事で詳しく解説しています。

rinker product advertising api
【Rinker】このアクセスキーは、Product Advertising APIにアクセスするために有効になっていません【対策方法】

商品リンクをかんたんに作れるWordPressプラグインとして、多くの利用者がいるというRinker(リンカー)
今回の記事ではこの「Rinker」で、Amazonの商品リンクが作成できない時の対策方法について解説します。

続きを見る

引用元:Rinker クリエイターズAPI修正

space 1




-サイト