Product Advertising API メモ
参考になった URL
API リファレンス http://docs.aws.amazon.com/AWSECommerceService/latest/DG/Welcome.html
Signature の作り方が分かり易く書いてある http://docs.aws.amazon.com/AWSECommerceService/latest/DG/rest-signature.html
Signature の確認。URL を貼ると正しい Signature 返してくれる http://associates-amazon.s3.amazonaws.com/signed-requests/helper/index.html
Signature
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/rest-signature.html の 9 番目の話。 Java で普通に URL エンコード(URLEncoder.encode)しても * - _の 3 つの記号がエンコードされない。Product Advertising API にはエンコードしたものを渡さないといけないので、普通にリプレイスした。
/**
* "-" と "_" も URL エンコードする
*
* @return URL エンコードした文字列
*/
public static String urlEncode(String text) {
try {
text = URLEncoder.encode(text, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
text = text.replaceAll("_", "%2F");
text = text.replaceAll("-", "%2B");
return text;
}
1/10 位の確率で 503 エラーになる
時間置いてリトライしないとダメ