<?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; API</title>
	<atom:link href="http://ueblog.natural-wave.com/tag/api/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/api/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>
		<item>
		<title>Googleのグラフが簡単に書けるAPI</title>
		<link>http://ueblog.natural-wave.com/2007/12/11/google-chart-api/</link>
		<comments>http://ueblog.natural-wave.com/2007/12/11/google-chart-api/#comments</comments>
		<pubDate>Mon, 10 Dec 2007 15:16:21 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/2007/12/11/google-chart-api/</guid>
		<description><![CDATA[とうとうGoogleからグラフを簡単に書けるAPIがでました！ 利用方法はimg srcタグにそのままAPIのURLを入れるだけでグラフ画像が生成される。 早速、試してみよう。 グラフの種類 Line Chart Bar Chart Pie Chart Venn diagrams Scatter plots APIについて グラフごとに必須となる項目（データ、ラベルなどの指定）]]></description>
			<content:encoded><![CDATA[<p>とうとうGoogleからグラフを簡単に書けるAPIがでました！</p>
<p>利用方法はimg srcタグにそのままAPIのURLを入れるだけでグラフ画像が生成される。<br />
早速、試してみよう。</p>
<h3>グラフの種類</h3>
<p><strong>Line Chart</strong><br />
<img src="http://chart.apis.google.com/chart?cht=lc&#038;chd=s:UVVUVVUUUVVUSSVVVXXYadfhjlllllllmmliigdbbZZXVVUUUTU&#038;chco=0000FF&#038;chls=2.0,1.0,0.0&#038;chxt=x,y&#038;chxl=0:|Jan|Feb|Mar|Jun|Jul|Aug|1:|0|25|50|75|100&#038;chs=350x150&#038;chg=100.0,25.0&#038;chf=c,ls,0,CCCCCC,0.2,ffffff,0.2"></p>
<p><strong>Bar Chart</strong><br />
<img src="http://chart.apis.google.com/chart?cht=bhs&#038;chco=ff0000,00ff00,0000ff,&#038;chs=350x150&#038;chd=s:FOE,THE,Bar&#038;chxt=x,y&#038;chxl=1:|Dec|Nov|Oct|0:||20K||60K||100K|"></p>
<p><strong>Pie Chart</strong><br />
<img src="http://chart.apis.google.com/chart?cht=p3&#038;chd=s:Uf9a&#038;chs=350x150&#038;chl=A|B|C|D"></p>
<p><strong>Venn diagrams</strong><br />
<img src="http://chart.apis.google.com/chart?cht=v&#038;chs=350x150&#038;chd=t:100,80,60,30,30,30,10"></p>
<p><strong>Scatter plots</strong><br />
<img src="http://chart.apis.google.com/chart?cht=s&#038;chd=s:984sttvuvkQIBLKNCAIi,DEJPgq0uov17zwopQODS,AFLPTXaflptx159gsDrn&#038;chxt=x,y&#038;chxl=0:|0|2|3|4|5|6|7|8|9|10|1:|0|25|50|75|100&#038;chs=350x150"></p>
<h3>APIについて</h3>
<p>グラフごとに必須となる項目（データ、ラベルなどの指定）がさまざま。バックグラウンドの色など含め、さまざまな効果をURLパラメータで指定できる。返ってくる画像はPNG方式。</p>
<p>パラメーターの意味はすこし難しいけど、これは便利だ！</p>
<p>利用方法的には、さまざまなデータをブログやインターネットサービスで公開するときが考えられるが、会社の売上げやら、サービスのPVなどをグラフ化しようとして、機密情報をGoogleに送るのはさすがにNGでしょう。（というか通信は暗号化されないので。）</p>
<p>詳しい仕様は下記へ<br />
<a href="http://code.google.com/apis/chart/" target="_blank">Developer's Guide - Google Chart API - Google Code</a></p>
<p>関連記事</p>
<blockquote><p><a href="http://www.ideaxidea.com/archives/2007/12/apigooglegoogle_charts.html" target="_blank">これは便利！誰でも簡単にグラフを描けるAPIがGoogleから登場！『Google Charts』</a></p>
<p><a href="http://blog.livedoor.jp/dankogai/archives/50964219.html" target="_blank">Google Code Chart - 折れ線グラフうぃざ～ど</a></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2007/12/11/google-chart-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2007/12/11/google-chart-api/" />
	</item>
		<item>
		<title>JavaでRESTするには(RestletによるAPI利用)</title>
		<link>http://ueblog.natural-wave.com/2007/12/10/java-rest/</link>
		<comments>http://ueblog.natural-wave.com/2007/12/10/java-rest/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 15:28:58 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[API]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/2007/12/10/java-rest/</guid>
		<description><![CDATA[Javaで各種WebのAPIにRESTするのに一番簡単な方法は？ いろんな手段がありえるが、今回は「Restlet」を取り上げてみる。 Restlet自体はAPIを提供する側のサーバ機能を利用することが多いようですが、今回はあえてクライアントとして利用します。 まずは、Restlet]]></description>
			<content:encoded><![CDATA[<p>Javaで各種WebのAPIにRESTするのに一番簡単な方法は？</p>
<p>いろんな手段がありえるが、今回は「<strong>Restlet</strong>」を取り上げてみる。<br />
Restlet自体はAPIを提供する側のサーバ機能を利用することが多いようですが、今回はあえてクライアントとして利用します。</p>
<p>まずは、Restletのライブラリをダウンロードする。<br />
<a href="http://www.restlet.org/downloads/" target="_blank">Restlet - Downloads</a></p>
<p>Zip archive版の中から、</p>
<blockquote><p>com.noelios.restlet.jar<br />
org.restlet.jar<br />
com.noelios.restlet.ext.httpclient_3.1.jar</p></blockquote>
<p>を取り出し、CLASSPATHに通す。</p>
<p>そして、commonsプロジェクトにも依存しているようなので、<br />
<a href="http://commons.apache.org/downloads/download_logging.cgi" target="_blank">Apache Commons - Logging Downloads</a></p>
<p><a href="http://commons.apache.org/downloads/download_codec.cgi" target="_blank">Apache Commons - Codec Downloads<br />
</a><br />
<a href="http://jakarta.apache.org/httpcomponents/httpclient-3.x/downloads.html" target="_blank">HttpClient - HttpClient Downloads</a></p>
<p>から、それぞれ</p>
<blockquote><p>commons-logging-1.1.jar<br />
commons-codec-1.3.jar<br />
commons-httpclient-3.1.jar</p></blockquote>
<p>を取り出し、CLASSPATHに通す。</p>
<p>さて、今日はどのAPIを標的とするかというと、、東京大学空間情報科学研究センターが提供する、住所から位置情報を割り出せるという<a href="http://pc035.tkl.iis.u-tokyo.ac.jp/~sagara/geocode/index.php" target="_blank">CSISシンプルジオコーディング</a>を利用してみようと思う。</p>
<p>さっそくコードはこんな感じに。東京都渋谷区道玄坂をターゲットにしてみました。</p>
<div class="igBar"><span id="ljava-6"><a href="#" onclick="javascript:showPlainTxt('java-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-6">
<div class="java">
<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: #a1a100;">import org.restlet.Client;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.restlet.data.Protocol;</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: #a1a100;">import org.restlet.data.Reference;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.restlet.resource.DomRepresentation;</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: #a1a100;">import org.w3c.dom.Node;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</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: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</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: #000000; font-weight: bold;">public</span> <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</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; &nbsp; &nbsp; &nbsp; &nbsp; Client client = <span style="color: #000000; font-weight: bold;">new</span> Client<span style="color: #66cc66;">&#40;</span>Protocol.<span style="color: #006600;">HTTP</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> url = <span style="color: #ff0000;">"http://geocode.csis.u-tokyo.ac.jp/cgi-bin/simple_geocode.cgi"</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; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + <span style="color: #ff0000;">"?addr="</span> + <a href="http://www.google.com/search?q=allinurl%3AReference+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Reference</span></a>.<span style="color: #006600;">encode</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"東京都渋谷区道玄坂"</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + <span style="color: #ff0000;">"&amp;charset=UTF8"</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; &nbsp; &nbsp; &nbsp; &nbsp; DomRepresentation xml = client.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>url<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getEntityAsDom</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Node n1 = xml.<span style="color: #006600;">getNode</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"//results/candidate/address"</span><span style="color: #66cc66;">&#41;</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; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"address : "</span> + n1.<span style="color: #006600;">getTextContent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Node n2 = xml.<span style="color: #006600;">getNode</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"//results/candidate/longitude"</span><span style="color: #66cc66;">&#41;</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; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"longitude : "</span> + n2.<span style="color: #006600;">getTextContent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Node n3 = xml.<span style="color: #006600;">getNode</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"//results/candidate/latitude"</span><span style="color: #66cc66;">&#41;</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; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"latitude : "</span> + n3.<span style="color: #006600;">getTextContent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </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; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #006600;">printStackTrace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</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; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</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: #66cc66;">&#125;</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: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
実行結果はこちら</p>
<blockquote><p>address : 東京都/渋谷区/道玄坂<br />
longitude : 139.698166<br />
latitude : 35.657429</p></blockquote>
<p>Clientのインスタンスを作って、URLを書き、そして簡単にxmlの解析ができます。超簡単！<br />
なんといっても、ソースが直感的。<br />
ライブラリの依存関係がうざいけど、シンプルなAPIにはかなり使えそうだ。</p>
<p>そして、このシンプルジオコーディング、かなりつかえるぞ！<br />
住所の文字列から住所の区分けまでやってくれます。さすが。</p>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2007/12/10/java-rest/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2007/12/10/java-rest/" />
	</item>
		<item>
		<title>HeartRails Express APIを利用して路線と駅のプルダウンをつくろう</title>
		<link>http://ueblog.natural-wave.com/2007/12/09/heartrails-express-api/</link>
		<comments>http://ueblog.natural-wave.com/2007/12/09/heartrails-express-api/#comments</comments>
		<pubDate>Sat, 08 Dec 2007 15:01:05 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[API]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/2007/12/09/heartrails-express-api/</guid>
		<description><![CDATA[路線や駅情報を提供してくれる、HeartRails ExpressのAPIを利用して、路線と駅のプルダウンを作成してみます。 HeartRails ExpressのAPIは、JSONPをサポートしているので、javascriptだけでできてしまいます。 利用するライブラリは、 JQuery selectタグの操作を楽にしてくれるJQueryのプラグイン JSONPをサポ]]></description>
			<content:encoded><![CDATA[<p>路線や駅情報を提供してくれる、<a href="http://express.heartrails.com/" target="_blank">HeartRails Express</a>のAPIを利用して、路線と駅のプルダウンを作成してみます。</p>
<p>HeartRails ExpressのAPIは、JSONPをサポートしているので、javascriptだけでできてしまいます。</p>
<p>利用するライブラリは、<br />
<a href="http://jquery.com/"  target="_blank">JQuery</a></p>
<p><a href="http://jqueryjs.googlecode.com/svn/trunk/plugins/selectboxes/" target="_blank">selectタグの操作を楽にしてくれるJQueryのプラグイン</a></p>
<p><a href="http://www.xml.com/pub/a/2005/12/21/json-dynamic-script-tag.html" target="_blank">JSONPをサポートしてくれるライブラリjsr_class.js</a></p>
<p>ダウンロードして、jsファイルをとりだし、下記のように宣言してあげます。</p>
<div class="igBar"><span id="ljavascript-10"><a href="#" onclick="javascript:showPlainTxt('javascript-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-10">
<div class="javascript">
<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;">&lt;script src=<span style="color: #3366CC;">"js/jquery-1.2.1.min.js"</span> type=<span style="color: #3366CC;">"text/javascript"</span>&gt;&lt;/script&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script src=<span style="color: #3366CC;">"js/jsr_class.js"</span> type=<span style="color: #3366CC;">"text/javascript"</span>&gt;&lt;/script&gt;</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;">&lt;script src=<span style="color: #3366CC;">"js/jquery.selectboxes.pack.js"</span> type=<span style="color: #3366CC;">"text/javascript"</span>&gt;&lt;/script&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
パスは適宜置き換えてください。</p>
<p>そして、実装コードはこんな感じになります。</p>
<div class="igBar"><span id="ljavascript-11"><a href="#" onclick="javascript:showPlainTxt('javascript-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-11">
<div class="javascript">
<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;">&lt;script type=<span style="color: #3366CC;">"text/javascript"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//&lt;![CDATA[</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: #009900; font-style: italic;">// 都道府県プルダウン変更時</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> prefObj = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</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: #003366; font-weight: bold;">function</span> PrefChange<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#pref"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</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: #003366; font-weight: bold;">var</span> url = <span style="color: #3366CC;">'http://express.heartrails.com/api/json?method=getLines'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; + <span style="color: #3366CC;">'&amp;prefecture='</span> + encodeURIComponent<span style="color: #66cc66;">&#40;</span> $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#pref"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</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; &nbsp; + <span style="color: #3366CC;">'&amp;jsonp=PrefCallback'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; prefObj = <span style="color: #003366; font-weight: bold;">new</span> JSONscriptRequest<span style="color: #66cc66;">&#40;</span> url <span style="color: #66cc66;">&#41;</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; prefObj.<span style="color: #006600;">buildScriptTag</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; prefObj.<span style="color: #006600;">addScriptTag</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</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; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</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: #66cc66;">&#40;</span><span style="color: #3366CC;">"#train"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">removeOption</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/./</span><span style="color: #66cc66;">&#41;</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; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</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: #003366; font-weight: bold;">function</span> PrefCallback<span style="color: #66cc66;">&#40;</span>json<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>!json<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span>; <span style="color: #66cc66;">&#125;</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; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>json.<span style="color: #006600;">response</span>.<span style="color: #006600;">line</span>.<span style="color: #006600;">length</span> == <span style="color: #CC0000;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span>; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</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; <span style="color: #003366; font-weight: bold;">var</span> lines = json.<span style="color: #006600;">response</span>.<span style="color: #006600;">line</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> options = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</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; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i = <span style="color: #CC0000;color:#800000;">0</span>; i &lt;lines.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; options<span style="color: #66cc66;">&#91;</span>lines<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span> = lines<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</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; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#train"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">removeOption</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/./</span><span style="color: #66cc66;">&#41;</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; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#train"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addOption</span><span style="color: #66cc66;">&#40;</span>options,<span style="color: #003366; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; prefObj.<span style="color: #006600;">removeScriptTag</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</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: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</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: #009900; font-style: italic;">// 路線プルダウン変更時</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> trainObj = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</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: #003366; font-weight: bold;">function</span> TrainChange<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#train"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</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: #003366; font-weight: bold;">var</span> url = <span style="color: #3366CC;">'http://express.heartrails.com/api/json?method=getStations'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; + <span style="color: #3366CC;">'&amp;line='</span> + encodeURIComponent<span style="color: #66cc66;">&#40;</span> $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#train"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</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; &nbsp; + <span style="color: #3366CC;">'&amp;jsonp=TrainCallback'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; trainObj = <span style="color: #003366; font-weight: bold;">new</span> JSONscriptRequest<span style="color: #66cc66;">&#40;</span> url <span style="color: #66cc66;">&#41;</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; trainObj.<span style="color: #006600;">buildScriptTag</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; trainObj.<span style="color: #006600;">addScriptTag</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</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; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</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: #66cc66;">&#40;</span><span style="color: #3366CC;">"#station"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">removeOption</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/./</span><span style="color: #66cc66;">&#41;</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; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</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: #003366; font-weight: bold;">function</span> TrainCallback<span style="color: #66cc66;">&#40;</span>json<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>!json<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span>; <span style="color: #66cc66;">&#125;</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; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>json.<span style="color: #006600;">response</span>.<span style="color: #006600;">station</span>.<span style="color: #006600;">length</span> == <span style="color: #CC0000;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span>; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</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; <span style="color: #003366; font-weight: bold;">var</span> stations = json.<span style="color: #006600;">response</span>.<span style="color: #006600;">station</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> options = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</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; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i = <span style="color: #CC0000;color:#800000;">0</span>; i &lt;stations.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; options<span style="color: #66cc66;">&#91;</span>stations<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #000066;">name</span><span style="color: #66cc66;">&#93;</span> = stations<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #000066;">name</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; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#station"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">removeOption</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066FF;">/./</span><span style="color: #66cc66;">&#41;</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; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"#station"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addOption</span><span style="color: #66cc66;">&#40;</span>options,<span style="color: #003366; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; trainObj.<span style="color: #006600;">removeScriptTag</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</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: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">//]]&gt;</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;">&lt;/script&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>HTMLはシンプルにこんな感じで。（都道府県は省略しました・・・。都道府県の値もAPIから取得できますが。手抜きで。）</p>
<div class="igBar"><span id="lhtml-12"><a href="#" onclick="javascript:showPlainTxt('html-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-12">
<div class="html">
<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: #009900;"><a href="http://december.com/html/4/element/select.html"><span style="color: #000000; font-weight: bold;">&lt;select</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"pref"</span> <span style="color: #000066;">onChange</span>=<span style="color: #ff0000;">"PrefChange();"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">&lt;option</span></a> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">""</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>都道府県を選択<span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option&gt;</span></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: #009900;"><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">&lt;option</span></a> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"東京都"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>東京都<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">&lt;option</span></a> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"神奈川県"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>神奈川県<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option&gt;</span></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: #009900;"><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">&lt;option</span></a> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"埼玉県"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>埼玉県<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">&lt;option</span></a> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"千葉県"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>千葉県<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option&gt;</span></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: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/select&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">&lt;br</span></a> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">&lt;br</span></a> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></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: #009900;"><a href="http://december.com/html/4/element/select.html"><span style="color: #000000; font-weight: bold;">&lt;select</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"train"</span> <span style="color: #000066;">onChange</span>=<span style="color: #ff0000;">"TrainChange();"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">&lt;option</span></a> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">""</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>路線を選択<span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option&gt;</span></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: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/select&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">&lt;br</span></a> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">&lt;br</span></a> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></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: #009900;"><a href="http://december.com/html/4/element/select.html"><span style="color: #000000; font-weight: bold;">&lt;select</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"station"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/option.html"><span style="color: #000000; font-weight: bold;">&lt;option</span></a> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">""</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>駅を選択<span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/option&gt;</span></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: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/select&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><a href="http://ueblog.natural-wave.com/sample/heartrails.html" target="_blank">サンプルはこちら</a></p>
<p>これは地図系のサイトでかなり使えそうですね。</p>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2007/12/09/heartrails-express-api/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2007/12/09/heartrails-express-api/" />
	</item>
	</channel>
</rss>

