{"id":1079,"date":"2009-08-21T15:50:34","date_gmt":"2009-08-21T06:50:34","guid":{"rendered":"http:\/\/nosaku.net\/?p=1079"},"modified":"2009-09-25T12:03:01","modified_gmt":"2009-09-25T03:03:01","slug":"amazon-showcase-wordpress-plugin","status":"publish","type":"post","link":"https:\/\/hidamari.kilo.jp\/nosaku\/archives\/1079","title":{"rendered":"Amazon Showcase WordPress Plugin"},"content":{"rendered":"<p class=\"imageframe alignleft\"><a title=\"amazon.co.jp mag\" href=\"http:\/\/www.flickr.com\/photos\/7940758@N07\/3355384235\/\" target=\"_blank\"><img decoding=\"async\" src=\"http:\/\/farm4.static.flickr.com\/3440\/3355384235_e3f3d17689_t.jpg\" border=\"0\" alt=\"amazon.co.jp mag\" \/><\/a><br \/><small><a title=\"Attribution License\" href=\"http:\/\/creativecommons.org\/licenses\/by\/2.0\/\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/nosaku.net\/wp\/wp-content\/plugins\/photo-dropper\/images\/cc.png\" border=\"0\" alt=\"Creative Commons License\" width=\"16\" height=\"16\" align=\"absmiddle\" \/><\/a> <a href=\"http:\/\/www.photodropper.com\/photos\/\" target=\"_blank\">photo<\/a> credit: <a title=\"mujitra (\u00b4\uff65\u03c9\uff65)\" href=\"http:\/\/www.flickr.com\/photos\/7940758@N07\/3355384235\/\" target=\"_blank\">mujitra (\u00b4\uff65\u03c9\uff65)<\/a><\/small><\/p>\n<p><a href=\"http:\/\/wordpress.org\/extend\/plugins\/amazon-showcase-wordpress-widget\/\">Amazon Showcase WordPress Plugin<\/a> \u306f\u3001\u30b5\u30a4\u30c9\u30d0\u30fc\u3067\u5546\u54c1\u3092\u7d39\u4ecb\u3067\u304d\u308b WordPress \u306e Widget\u3067\u3059\u3002\u30b7\u30f3\u30d7\u30eb\u306b\u5199\u771f\u3060\u3051\u63b2\u8f09\u3067\u304d\u308b\u306e\u3067\uff08\u8ca9\u4fc3\u52b9\u679c\u306f\u306a\u3055\u305d\u3046\u3060\u3051\u3069\uff09\u6c17\u306b\u5165\u3063\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u7a81\u7136\u52d5\u4f5c\u3057\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002(Ver2.0\u6642\u70b9)<\/p>\n<p>2009\/09\/25\u8ffd\u8a18<br \/>\nProduct Advertising API \u306b\u5bfe\u5fdc\u3057\u305f Ver2.1\u304c\u51fa\u3066\u3044\u305f\u306e\u3060\u3051\u3069\u3001\u4f55\u6545\u7a3c\u50cd\u3055\u305b\u305a\u3002<br \/>\n\u3067\u3001Ver2.2\u304c\u51fa\u3066\u3001\u3061\u3083\u3093\u3068\u52d5\u304f\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u3081\u3067\u305f\u3057\u3002<br \/>\n\u4e00\u30ab\u6240\u3060\u3051\u4fee\u6b63\u3059\u3079\u304d\u7b87\u6240\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>amazonshowcase.php (Ver2.2)<\/p>\n<p>[sourcecode language=&#8221;php&#8221; firstline=&#8221;564&#8243;]<br \/>\ncase &#8216;jp&#8217;: $base = &#8216;ecs.amazonaws.co.jp&#8217;; break;<br \/>\n[\/sourcecode]<\/p>\n<p>\u3053\u306e\u30a2\u30c9\u30ec\u30b9\u304c\u76f8\u5909\u308f\u3089\u305a\u9593\u9055\u3063\u3066\u3044\u3066\u3001co.jp \u306e co. \u3092\u3068\u3063\u3066\u3001ecs.amazonaws.jp \u306b\u3059\u308c\u3070OK\u3002<\/p>\n<p><!--more--><\/p>\n<p>2009\/09\/25\u8ffd\u8a18<br \/>\n\u4ee5\u4e0b\u3001\u30aa\u30ea\u30b8\u30ca\u30eb\u306e\u30a8\u30f3\u30c8\u30ea\uff0d\u3002Ver2.0\u306e\u6642\u4ee3\u306e\u7269\u3067\u3082\u306f\u3084\u6d0b\u306a\u3057\u3002<\/p>\n<p>\u3069\u3046\u3082\u3001Product Advertising API \u306e\u5909\u66f4\u306b\u3088\u308b\u3082\u306e\u3089\u3057\u3044\u3002<\/p>\n<blockquote>\n<p><a href=\"http:\/\/developer.amazonwebservices.com\/connect\/ann.jspa?annID=442\">http:\/\/developer.amazonwebservices.com\/connect\/ann.jspa?annID=442<\/a>\n<\/p>\n<p>\u91cd\u8981\uff1a2009\u5e748\u670815\u65e5\u3092\u3082\u3063\u3066\u3001Product Advertising API \u306f\u3001\u7f72\u540d\u8a8d\u8a3c\u3092\u542b\u307e\u306a\u3044\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4e00\u5207\u51e6\u7406\u3057\u306a\u304f\u306a\u308a\u307e\u3059\u3002\u73fe\u5728\u3001Product Advertising API \u3092\u5229\u7528\u3055\u308c\u3066\u3044\u308b\u65b9\u306f\u3001\u4eca\u3059\u3050\u3054\u5229\u7528\u4e2d\u306e\u3059\u3079\u3066\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u306b\u7f72\u540d\u8a8d\u8a3c\u3092\u542b\u3081\u308b\u6e96\u5099\u3092\u958b\u59cb\u3044\u305f\u3060\u3051\u307e\u3059\u3088\u3046\u304a\u9858\u3044\u3044\u305f\u3057\u307e\u3059\u3002<\/p>\n<\/blockquote>\n<p>\u3072\uff5e\u3002\u3063\u3066\u611f\u3058\u3067\u30b0\u30b0\u3063\u3066\u3001\u3053\u3061\u3089\u3092\u53c2\u8003\u306b\u30bd\u30fc\u30b9\u3092\u4fee\u6b63\u3057\u307e\u3057\u305f\u3002<\/p>\n<blockquote>\n<p>\u3082\u3084\u3057\u65e5\u8a18<br \/>\n<a href=\"http:\/\/d.hatena.ne.jp\/p4life\/20090510\/1241954889\">Amazon Product Advertising API \u3078\u306e\u5bfe\u5fdc\uff08PHP\u7248\uff09<\/a><\/p>\n<\/blockquote>\n<p>amazonshowcase.php\u306e515\u884c\u76ee\u304b\u3089\u59cb\u307e\u308b\u3001Sends http request to Amazon web service\u306e funciton ItemSearch()\u306e\u524d\u306b\u3001<br \/>\nfunction urlencode_rfc3986($str) \u3092\u8ffd\u52a0\u3057\u3001<br \/>unciton ItemSearch()\u306e\u4e2d\u8eab\u3092\u3001AccessKey \u3092\u4f7f\u3046\u5f62\u306b\u66f8\u304d\u63db\u3048\u307e\u3057\u305f\u3002<\/p>\n<p>543\u884c\u76ee\u306b Access Key\u3001543\u884c\u76ee\u306b Secret Access Key \u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002<\/p>\n<p>[sourcecode language=&#8221;php&#8221; firstline=&#8221;515&#8243;]<br \/>\n\t\/**<br \/>\n\t * Sends http request to Amazon web service<br \/>\n\t *<br \/>\n\t * @param array $asins<br \/>\n\t * @param string $associateId<br \/>\n\t * @param string $locale<br \/>\n\t * @return xml Amazon API Response<br \/>\n\t *\/<br \/>\n\tfunction urlencode_rfc3986($str) {<br \/>\n\t\treturn str_replace(&#8216;%7E&#8217;, &#8216;~&#8217;, rawurlencode($str));<br \/>\n\t}<\/p>\n<p>\tfunction ItemSearch($asins = array(), $associateId = null, $locale = &#8216;us&#8217;) {<br \/>\n\t\t\t\/\/Set the values for some of the parameters.<br \/>\n\t\t\t$associateId = empty($associateId) ? $this-&gt;_AssociateId : $associateId;<\/p>\n<p>\t\tif (is_array($asins) &amp;&amp; !empty($asins)) {<br \/>\n\t\t\t\/\/Set the values for some of the parameters.<\/p>\n<p>\t\t\tswitch ($locale) {<br \/>\n\t\t\t\tcase &#8216;uk&#8217;: $base = &#8216;http:\/\/ecs.amazonaws.co.uk\/onca\/xml&#8217;; break;<br \/>\n\t\t\t\tcase &#8216;de&#8217;: $base = &#8216;http:\/\/ecs.amazonaws.de\/onca\/xml&#8217;; break;<br \/>\n\t\t\t\tcase &#8216;jp&#8217;: $base = &#8216;http:\/\/ecs.amazonaws.jp\/onca\/xml&#8217;; break;<br \/>\n\t\t\t\tcase &#8216;fr&#8217;: $base = &#8216;http:\/\/ecs.amazonaws.fr\/onca\/xml&#8217;; break;<br \/>\n\t\t\t\tcase &#8216;ca&#8217;: $base = &#8216;http:\/\/ecs.amazonaws.ca\/onca\/xml&#8217;; break;<br \/>\n\t\t\t\tdefault: $base = &#8216;http:\/\/ecs.amazonaws.com\/onca\/xml&#8217;; break;<br \/>\n\t\t\t}<\/p>\n<p>\t\t\t\/\/Set Access key<br \/>\n\t\t\t$AWSAccessKeyId = &#8216;\u2605Set! Your Access Key ID&#8217;;<br \/>\n\t\t\t$secret_access_key = &#8216;\u2605Set! Your Secret Access Key&#8217;;<\/p>\n<p>\t\t\t$params = array();<br \/>\n\t\t\t$params[&#8216;Service&#8217;]        = &#8216;AWSECommerceService&#8217;;<br \/>\n\t\t\t$params[&#8216;AssociateTag&#8217;]   = $associateId;<br \/>\n\t\t\t$params[&#8216;AWSAccessKeyId&#8217;] = $AWSAccessKeyId;<br \/>\n\t\t\t$params[&#8216;Version&#8217;]        = &#8216;2009-07-01&#8217;;<br \/>\n\t\t\t$params[&#8216;Operation&#8217;]      = &quot;ItemLookup&quot;;<br \/>\n\t\t\t$params[&#8216;ItemId&#8217;]         = implode(&#8216;,&#8217;, $asins);<br \/>\n\t\t\t$params[&#8216;ResponseGroup&#8217;]  = &quot;Small,Images&quot;;<br \/>\n\t\t\t$params[&#8216;Timestamp&#8217;]      = gmdate(&#8216;Y-m-d\\TH:i:s\\Z&#8217;);<\/p>\n<p>\t\t\tksort($params);<\/p>\n<p>\t\t\t$canonical_string = &#8221;;<br \/>\n\t\t\tforeach ($params as $k =&gt; $v) {<br \/>\n\t\t\t\t$canonical_string .= &#8216;&amp;&#8217;.$this-&gt;urlencode_rfc3986($k).&#8217;=&#8217;.$this-&gt;urlencode_rfc3986($v);<br \/>\n\t\t\t}<br \/>\n\t\t\t$canonical_string = substr($canonical_string, 1);<\/p>\n<p>\t\t\t$parsed_url = parse_url($base);<br \/>\n\t\t\t$string_to_sign = &quot;GET\\n{$parsed_url[&#8216;host&#8217;]}\\n{$parsed_url[&#8216;path&#8217;]}\\n{$canonical_string}&quot;;<br \/>\n\t\t\t$signature = base64_encode(hash_hmac(&#8216;sha256&#8242;, $string_to_sign, $secret_access_key, true));<\/p>\n<p>\t\t\t$url = $base.&#8217;?&#8217;.$canonical_string.&#8217;&amp;Signature=&#8217;.$this-&gt;urlencode_rfc3986($signature);<\/p>\n<p>\t\t\t\/\/Catch the response in the $response object<br \/>\n\t\t\t$response = getUrl($url);<\/p>\n<p>\t\t\treturn $response;<br \/>\n\t\t}<\/p>\n<p>\t\treturn false;<br \/>\n\t}<br \/>\n[\/sourcecode]<\/p>\n<p>\u30d5\u30a9\u30fc\u30e0\u304b\u3089 Secret Access Key\u306a\u3069\u3092\u8a2d\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u6539\u9020\u3059\u308c\u3070\u3044\u3044\u306e\u3060\u308d\u3046\u3051\u3069\u3001\u3068\u308a\u3042\u3048\u305a\u3001\u3053\u308c\u3067\u4e8b\u8db3\u308a\u305f\u306e\u3067\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>photo credit: mujitra (\u00b4\uff65\u03c9\uff65) Amazon Showcase WordPress Plugin \u306f\u3001\u30b5\u30a4\u30c9\u30d0\u30fc\u3067\u5546\u54c1\u3092\u7d39\u4ecb\u3067\u304d\u308b WordPress \u306e Widget\u3067\u3059\u3002\u30b7\u30f3\u30d7\u30eb\u306b\u5199\u771f\u3060\u3051\u63b2 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[18],"tags":[21,23,20,19],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pFhgl-hp","_links":{"self":[{"href":"https:\/\/hidamari.kilo.jp\/nosaku\/wp-json\/wp\/v2\/posts\/1079"}],"collection":[{"href":"https:\/\/hidamari.kilo.jp\/nosaku\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hidamari.kilo.jp\/nosaku\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hidamari.kilo.jp\/nosaku\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hidamari.kilo.jp\/nosaku\/wp-json\/wp\/v2\/comments?post=1079"}],"version-history":[{"count":0,"href":"https:\/\/hidamari.kilo.jp\/nosaku\/wp-json\/wp\/v2\/posts\/1079\/revisions"}],"wp:attachment":[{"href":"https:\/\/hidamari.kilo.jp\/nosaku\/wp-json\/wp\/v2\/media?parent=1079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hidamari.kilo.jp\/nosaku\/wp-json\/wp\/v2\/categories?post=1079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hidamari.kilo.jp\/nosaku\/wp-json\/wp\/v2\/tags?post=1079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}