<?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/"
	>

<channel>
	<title>cap&#039;n webb &#187; twitter</title>
	<atom:link href="http://blog.dataich.com/tag/twitter/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dataich.com</link>
	<description>almost all things about it</description>
	<lastBuildDate>Thu, 12 Jan 2012 03:38:00 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Adobe Airでtwitterタイムラインを取得してみよう。</title>
		<link>http://blog.dataich.com/2008/07/01/adobe-air%e3%81%a7twitter%e3%82%bf%e3%82%a4%e3%83%a0%e3%83%a9%e3%82%a4%e3%83%b3%e3%82%92%e5%8f%96%e5%be%97%e3%81%97%e3%81%a6%e3%81%bf%e3%82%88%e3%81%86%e3%80%82/</link>
		<comments>http://blog.dataich.com/2008/07/01/adobe-air%e3%81%a7twitter%e3%82%bf%e3%82%a4%e3%83%a0%e3%83%a9%e3%82%a4%e3%83%b3%e3%82%92%e5%8f%96%e5%be%97%e3%81%97%e3%81%a6%e3%81%bf%e3%82%88%e3%81%86%e3%80%82/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 00:56:50 +0000</pubDate>
		<dc:creator>dataich</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://dataich.s15.coreserver.jp/blog/2008/07/01/adobe-air%e3%81%a7twitter%e3%82%bf%e3%82%a4%e3%83%a0%e3%83%a9%e3%82%a4%e3%83%b3%e3%82%92%e5%8f%96%e5%be%97%e3%81%97%e3%81%a6%e3%81%bf%e3%82%88%e3%81%86%e3%80%82/</guid>
		<description><![CDATA[前提条件 Adobe Flex Builder3がインストール済みであること。（Eclipseプラグインでも可） ※ダウンロード、インストール方法については、下記Adobeサイトを参照してください。 Adobe &#82 [...]]]></description>
			<content:encoded><![CDATA[<div class="section">
<h4>前提条件</h4>
<p>Adobe Flex Builder3がインストール済みであること。（Eclipseプラグインでも可）</p>
<p>※ダウンロード、インストール方法については、下記Adobeサイトを参照してください。</p>
<p><a href="http://www.adobe.com/jp/products/flex/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.adobe.com/jp/products/flex/?referer=');">Adobe &#8211; Flex 3</a></p>
<h4>Flex Builder（または、Eclipse）上でのプロジェクト作成</h4>
<p>1.File &gt; New &gt; Flex Project（見つからない場合は、Otherより探してください。）を選択。</p>
<p>2.プロジェクト名を&#8217;twitter&#8217;（任意）とし、アプリケーションの種類を&#8217;デスクトップアプリケーション（Adobe Air&#8230;）&#8217;としてFinishを選択。これで下記構成プロジェクトが作成されます。</p>
<blockquote>
<ul>
<li>twitter
<ul>
<li>bin-debug</li>
<li>libs</li>
<li>src
<ul>
<li>twitter.mxml</li>
<li>twitter-app.xml</li>
</ul>
</li>
</ul>
</li>
</ul>
</blockquote>
<h4>ひとまず、Airアプリケーションを実行してみましょう。</h4>
<ol>
<li>プロジェクト&#8217;twitter&#8217;を右クリック &gt; Run As &gt; Adobe Air アプリケーションを選択。</li>
<li>別画面でAirアプリケーションが起動するはずです。もちろんまだ何もコーディングしていませんので、何も無いウィンドウが表示されるだけです。</li>
</ol>
<h4>twitterのタイムラインを表示するための画面コンポーネントの作成</h4>
<p>twitterのタイムラインを表示するためのコンポーネントとして、ここではmx:DataGridコンポーネントを使用します。</p>
<ol>
<li>twitter.mxmlをダブルクリックし、エディターに表示させ、デザインタブをクリック。</li>
<li>コンポーネントビューのコントロール/DataGridコンポーネントをデザインエディタにドラッグ。</li>
<li>Airアプリケーションを実行して、確認してください。何もなかったウィンドウにDataGridが表示されてます。</li>
</ol>
<h4>twitter apiを使用してタイムラインを取得する。</h4>
<p>1.まずは、twitterのAPIと通信を行うための、mx:HTTPServiceを作成します。</p>
<p>twitter.mxmlをダブルクリックし、エディターに表示させ、ソースタブをクリック。mx:WindowedApplicationタグ内に、下記を追加します。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:HTTPService</span></span>
<span style="color: #009900;">  <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;twitter_timeline&quot;</span></span>
<span style="color: #009900;">  <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;http://twitter.com/statuses/public_timeline.xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>2.アプリケーション開始時に、このHTTPServiceで通信するよう、mx:WindowedApplicationのcreationCompleteイベント属性に、&#8217;twitter_timeline.send()&#8217;と記述します。</p>
<p>3.ここまでで、下記のようになるかと思います。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:WindowedApplication</span> <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> <span style="color: #000066;">layout</span>=<span style="color: #ff0000;">&quot;absolute&quot;</span> <span style="color: #000066;">creationComplete</span>=<span style="color: #ff0000;">&quot;twitter_timeline.send()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:HTTPService</span></span>
<span style="color: #009900;">    <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;twitter_timeline&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;http://twitter.com/statuses/public_timeline.xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
      ...省略
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:WindowedApplication<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>4.次に、取得したタイムラインを最初に作成したDataGridに表示させます。</p>
<p>twitterのタイムラインAPIからは、XMLが取得できます。どういうXMLが取得できるかは、<a href="http://twitter.com/statuses/public_timeline.xml" target="_blank" onclick="pageTracker._trackPageview('/outgoing/twitter.com/statuses/public_timeline.xml?referer=');">http://twitter.com/statuses/public_timeline.xml</a>にブラウザでアクセスして確認してみてください。</p>
<p>取得したXMLをDataGridに表示させるには、dataProviderを使用します。ここにはXMLオブジェクト等を指定することができます。具体的にはdataProvider=&#8221;{twitter_timeline.lastResult.statuses.status}&#8221;とします。これは、HTTPServiceであるtwitter_timeline(ID)のlastResultファンクション（取得した内容（オブジェクト、ここではXMLオブジェクト）を返す）のstatusesタグの、statusタグを指定していることになります。</p>
<p>そして、DataGridのカラムであるmx:DataGridColumnのdataField属性に、&#8221;text&#8221;と記述します。これはstatusタグのtextタグの内容をセットしています。後はこれがstatusタグの回数分、自動的に出力されます。Airアプリケーションを実行して確認してみてください。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:DataGrid</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">dataProvider</span>=<span style="color: #ff0000;">&quot;{twitter_timeline.lastResult.statuses.status}&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:columns<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:DataGridColumn</span> <span style="color: #000066;">headerText</span>=<span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">dataField</span>=<span style="color: #ff0000;">&quot;text&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:columns<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:DataGrid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>5.次に、screen_nameを取得します。</p>
<p>screen_nameはstatusタグのuserタグの中にあります。通常、DataGridタグ内では、{data}として、dataProviderのデータを取得できます。但し、dataField属性には、使用できません。そこでmx:itemRendererを使用します。これでDaraGridColumn内のレンダリングコンポーネントを差し替えることができます。下記のようにして、mx:labelコンポーネントに差し替えてtext属性に{data.user.screen_name}をセットしています。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:DataGridColumn</span> <span style="color: #000066;">headerText</span>=<span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:itemRenderer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;{data.user.screen_name}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:itemRenderer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:DataGridColumn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>6.次に、ユーザの画像を表示してみます。</p>
<p>DataGridColumnに画像を表示するには、itemRendererにmx.controls.Imageを指定します。これにより、このmx.controls.Imageのsource属性にURLをセットすることで画像として表示されます。ここまで全て合わせると下記のようになります。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:WindowedApplication</span> <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> <span style="color: #000066;">layout</span>=<span style="color: #ff0000;">&quot;absolute&quot;</span> <span style="color: #000066;">creationComplete</span>=<span style="color: #ff0000;">&quot;twitter_timeline.send()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:HTTPService</span></span>
<span style="color: #009900;">    <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;twitter_timeline&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;http://twitter.com/statuses/public_timeline.xml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:DataGrid</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">dataProvider</span>=<span style="color: #ff0000;">&quot;{twitter_timeline.lastResult.statuses.status}&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:columns<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:DataGridColumn</span> <span style="color: #000066;">headerText</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:itemRenderer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Image</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;{data.user.profile_image_url}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:itemRenderer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:DataGridColumn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:DataGridColumn</span> <span style="color: #000066;">headerText</span>=<span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:itemRenderer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Label</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;{data.user.screen_name}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:itemRenderer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:DataGridColumn<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:DataGridColumn</span> <span style="color: #000066;">headerText</span>=<span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">dataField</span>=<span style="color: #ff0000;">&quot;text&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:columns<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:DataGrid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:WindowedApplication<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>これでAirアプリケーションを実行してみてください。タイムラインが表示されます。</p></div>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://blog.dataich.com/2008/07/01/adobe-air%e3%81%a7twitter%e3%82%bf%e3%82%a4%e3%83%a0%e3%83%a9%e3%82%a4%e3%83%b3%e3%82%92%e5%8f%96%e5%be%97%e3%81%97%e3%81%a6%e3%81%bf%e3%82%88%e3%81%86%e3%80%82/&via=dataich&text=Adobe Airでtwitterタイムラインを取得してみよう。&related=:&lang=en&count=vertical" class="twitter-share-button" onclick="pageTracker._trackPageview('/outgoing/twitter.com/share?url=http_//blog.dataich.com/2008/07/01/adobe-air_e3_81_a7twitter_e3_82_bf_e3_82_a4_e3_83_a0_e3_83_a9_e3_82_a4_e3_83_b3_e3_82_92_e5_8f_96_e5_be_97_e3_81_97_e3_81_a6_e3_81_bf_e3_82_88_e3_81_86_e3_80_82/_via=dataich_text=Adobe_Air_twitter_related=_lang=en_count=vertical&amp;referer=');">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.dataich.com/2008/07/01/adobe-air%e3%81%a7twitter%e3%82%bf%e3%82%a4%e3%83%a0%e3%83%a9%e3%82%a4%e3%83%b3%e3%82%92%e5%8f%96%e5%be%97%e3%81%97%e3%81%a6%e3%81%bf%e3%82%88%e3%81%86%e3%80%82/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

