<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>ueblog &#187; Amazon</title>
	<atom:link href="http://ueblog.natural-wave.com/tag/amazon/feed/" rel="self" type="application/rss+xml" />
	<link>http://ueblog.natural-wave.com</link>
	<description>Web関連のネタを中心に役立つ情報を配信しています。</description>
	<lastBuildDate>Wed, 11 Jan 2012 00:51:56 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/tag/amazon/feed/" />
		<item>
		<title>Zend_Service_AmazonのAmazon新API対応について</title>
		<link>http://ueblog.natural-wave.com/2009/08/08/zend_service_amazon-new-api/</link>
		<comments>http://ueblog.natural-wave.com/2009/08/08/zend_service_amazon-new-api/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 06:47:43 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[API]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/?p=504</guid>
		<description><![CDATA[Amazon APIを利用している方、新しい認証方法に対応してますか～？ 2009年8月16日からAmazon APIの認証方法が変更されるにあたって、利用している方は対応が必要です。 かなりざっくり説明すると、 URLにtimestampを付与 URLパラメータをアルファベット順にソート パラ]]></description>
			<content:encoded><![CDATA[<p><strong>Amazon API</strong>を利用している方、新しい認証方法に対応してますか～？</p>
<p>2009年8月16日からAmazon APIの認証方法が変更されるにあたって、利用している方は対応が必要です。</p>
<p>かなりざっくり説明すると、</p>
<ul>
<li>URLにtimestampを付与</li>
<li>URLパラメータをアルファベット順にソート</li>
<li>パラメータにAmazonから新しく付与されているキーを元にハッシュ化しURLエンコード</li>
<li>ハッシュ化されたキーをURLにくっつけて、APIにアクセス！</li>
</ul>
<p>と言った具合。詳しくは</p>
<p><a href="http://chalow.net/2009-05-09-1.html" target="_blank">[を] アマゾンAPIを使うのに2009年8月15日から認証が必要になるらしい</a></p>
<p>こちらを参照。</p>
<p>さて本題、<strong>Zend_Service_Amazon</strong>を利用している場合はどうすればよいか。</p>
<p>実はとても簡単。Zend_Service_APIオブジェクトをnewするときの第3引数にAmazonから付与される、Secret Access Keyを指定するだけ！</p>
<p>まずは、<a href="http://aws.amazon.com/" target="_blank">Amazon Web Services</a>でログインしてから、上部メニューの「Your Account」⇒「Access Identifiers」へ行き、<strong>Your Secret Access Key:</strong>と書かれている部分をコピーしておく。</p>
<p>このSecret Access Keyをnew Zend_Service_APIしているソースの第3引数に指定しよう。</p>
<div class="igBar"><span id="lphp-3"><a href="#" onclick="javascript:showPlainTxt('php-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-3">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$amazon</span> = <span style="color:#000000; font-weight:bold;">new</span> Zend_Service_Amazon<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Access Key'</span>, <span style="color:#FF0000;">'JP'</span>, <span style="color:#FF0000;">'Secret Access Key'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$result</span> = <span style="color:#0000FF;">$amazon</span>-&gt;<span style="color:#006600;">ItemLookup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$item_code</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF0000;">'AssociateTag'</span>&nbsp; =&gt; <span style="color:#FF0000;">'associate_tag'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF0000;">'ResponseGroup'</span> =&gt; <span style="color:#FF0000;">'Large'</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
以上終了！Zend使っててよかった～</p>
<p>ちなみに2009年7月26日に更新されたようなので、zendのアップグレードをしていない方は、ソースを落とすなり、「<strong>pear upgrade zend/zend」</strong>しておきましょう。</p>
<p>ちなみにZend_Service_Amazonコンストラクターのphpdocはこんな感じ。</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showPlainTxt('php-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * Constructs a new Amazon Web Services Client</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> *</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @param&nbsp; string $appId&nbsp; &nbsp; &nbsp; &nbsp;Developer's Amazon appid</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @param&nbsp; string $countryCode Country code for Amazon service; may be US, UK, DE, JP, FR, CA</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @throws Zend_Service_Exception</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @return Zend_Service_Amazon</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;public <span style="color:#000000; font-weight:bold;">function</span> __construct<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$appId</span>, <span style="color:#0000FF;">$countryCode</span> = <span style="color:#FF0000;">'US'</span>, <span style="color:#0000FF;">$secretKey</span> = <span style="color:#000000; font-weight:bold;">null</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
あれ第3引数のdocumentが書かれてない。。でもちゃんと実装はされていて動作もしたので念のため。</p>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2009/08/08/zend_service_amazon-new-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2009/08/08/zend_service_amazon-new-api/" />
	</item>
	</channel>
</rss>

