Services_Amazonで商品情報を取得
今マンガ関係のサイトを作ってて、ISBNから書影とかURLを拾ってきたい。んで使ったのがPEAR::Services_Amazon。pear install services_amazonでとってこれます。
んで
(開発者の方のサイト、「Amazon Product Advertising API への対応(PHP版) - もやし日記」から引用)
$amazon = new Services_Amazon(ACCESS_KEY_ID, SECRET_ACCESS_KEY);
$amazon->ItemSearch(...);
こう。ItemSearchの中身で詰まったのですが、Amazon Web サービス入門(Product Advertising API)で見てなんとかなりそう。
で、$resultの中に連想配列で色々入ってるので、例えば大サイズの書影を出すなら
$amazon = new Services_Amazon($access_key_id, $secret_access_key);
$amazon->setBaseUrl('http://ecs.amazonaws.jp/onca/xml');
$amazon->setLocale('JP');
$isbn = '4088725093';
$options['Sort'] = 'salesrank';
$options['IdType'] = 'ISBN';
$options['AssociateTag'] = 'hogehoge-22';
$options['SearchIndex'] = 'Books';
$options['ResponseGroup'] = 'ItemIds,ItemAttributes,Images';
$result = $amazon->ItemLookup($isbn,$options);
print ('<img src="' . $result[Item][0][LargeImage][URL] . '" />');
で。