<?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>Silveira Neto &#187; twitter</title>
	<atom:link href="http://silveiraneto.net/tag/twitter/feed/" rel="self" type="application/rss+xml" />
	<link>http://silveiraneto.net</link>
	<description>the world is a pixel</description>
	<lastBuildDate>Sun, 08 Jan 2012 05:17:57 +0000</lastBuildDate>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Twitter Bot @rudaufc versão 1</title>
		<link>http://silveiraneto.net/2009/11/09/twitter-bot-rudaufc-versao-1/</link>
		<comments>http://silveiraneto.net/2009/11/09/twitter-bot-rudaufc-versao-1/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 19:54:18 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[português]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[Comida]]></category>
		<category><![CDATA[CRON]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[culinária]]></category>
		<category><![CDATA[CURL]]></category>
		<category><![CDATA[ia]]></category>
		<category><![CDATA[inteligência artificial]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Restaurante Universitário]]></category>
		<category><![CDATA[robô]]></category>
		<category><![CDATA[robot]]></category>
		<category><![CDATA[SH]]></category>
		<category><![CDATA[Shell Script]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[ufc]]></category>
		<category><![CDATA[Universidade Federal do Ceará]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=2927</guid>
		<description><![CDATA[Este aqui é um bot bem simples para Twitter. Diariamente, as nove da manhã ele posta qual vai ser o cardápio do RU (Restaurante Universitário) da UFC naquele dia. Assim, quando vai batendo a hora da fome, os alunos podem entrar no perfil @rudaufc e olhar qual vai ser o prato do dia, ou quem [...]]]></description>
			<content:encoded><![CDATA[<p><center><img src="http://silveiraneto.net/wp-content/uploads/2009/11/robo.jpg" alt="robô" title="robô" width="117" height="227" class="alignnone size-full wp-image-2933" /></center></p>
<p>Este aqui é um bot bem simples para Twitter.</p>
<p>Diariamente, as nove da manhã ele posta qual vai ser o cardápio do RU (<a href="http://www.ufc.br/portal/index.php?option=com_content&#038;task=view&#038;id=6842&#038;Itemid=87">Restaurante Universitário</a>) da <a href="http://www.ufc.br">UFC</a> naquele dia.</p>
<p>Assim, quando vai batendo a hora da fome, os alunos podem entrar no perfil <a href="http://www.twitter.com/rudaufc">@rudaufc</a> e olhar qual vai ser o prato do dia, ou quem está seguindo ele no Twitter pode ter a agradável surpresa de ver todo dia o que vai ser servido hoje.</p>
<p>Aqui está o código fonte do arquivo rudaufc.sh:</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;"># Twitter bot @rudaufc</span>
<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">login</span></span>=<span style="color: #ff0000;">&quot;rudaufc&quot;</span>
<span style="color: #007800;">senha</span>=<span style="color: #ff0000;">&quot;suasenhaaqui&quot;</span>
&nbsp;
<span style="color: #007800;">segunda</span>=<span style="color: #ff0000;">&quot;Picadinho com legumes ou bife na chapa. Salada de macarrão com cenoura. Arroz. Feijão com abóbora e batata doce.&quot;</span>
<span style="color: #007800;">terca</span>=<span style="color: #ff0000;">&quot;Franco guisado ou coxas de frango ao forno . Salada de acelga, cenoura e passas. Arroz. Feijão com abóbora e batata doce.&quot;</span>
<span style="color: #007800;">quarta</span>=<span style="color: #ff0000;">&quot;# Feijoada à moda RU ou bisteca . Salada de repolho branco, cenoura e abacaxi. Arroz. Feijão com abóbora e batata doce&quot;</span>
<span style="color: #007800;">quinta</span>=<span style="color: #ff0000;">&quot;Frango à passarinho ou frango chinês. Salada de Alface, Tomate e Cebola. Arroz. Feijão com abóbora e batata doce.&quot;</span>
<span style="color: #007800;">sexta</span>=<span style="color: #ff0000;">&quot;# Isca ao molho ou maravilha de carne. Salada de acelga com cenoura. Arroz. Feijão com abóbora e batata doce.&quot;</span>
&nbsp;
<span style="color: #007800;">dia</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span><span style="color: #c20cb9; font-weight: bold;">w</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">log</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y-<span style="color: #000000; font-weight: bold;">%</span>m-<span style="color: #000000; font-weight: bold;">%</span>d-<span style="color: #000000; font-weight: bold;">%</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #ff0000;">&quot;-$$.log&quot;</span>
<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">dir</span></span>=<span style="color: #ff0000;">&quot;/home/silveiraneto/rudaufc&quot;</span>
<span style="color: #007800;">msg</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$dia&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
<span style="color: #666666; font-style: italic;">#	&quot;0&quot;) msg=$domingo ;;</span>
	<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">msg</span>=<span style="color: #007800;">$segunda</span> ;;
	<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">msg</span>=<span style="color: #007800;">$terca</span> ;;
	<span style="color: #ff0000;">&quot;3&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">msg</span>=<span style="color: #007800;">$quarta</span> ;;
	<span style="color: #ff0000;">&quot;4&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">msg</span>=<span style="color: #007800;">$quinta</span> ;;
	<span style="color: #ff0000;">&quot;5&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">msg</span>=<span style="color: #007800;">$sexta</span> ;;
<span style="color: #666666; font-style: italic;">#	&quot;6&quot;) msg=$sabado ;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
curl <span style="color: #660033;">-u</span> <span style="color: #007800;">$login</span>:<span style="color: #007800;">$senha</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">status</span>=<span style="color: #ff0000;">&quot;$msg&quot;</span> http:<span style="color: #000000; font-weight: bold;">//</span>twitter.com<span style="color: #000000; font-weight: bold;">/</span>statuses<span style="color: #000000; font-weight: bold;">/</span>update.xml <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$log</span></pre>
</div>
</div>
<p>A mágica toda está na capacidade do <a href="http://en.wikipedia.org/wiki/CURL">Curl</a> de acessar facilmente a <a href="http://apiwiki.twitter.com/">API do Twitter</a> para enviar mensagens.</p>
<p>Para que o script execute diariamente as nove da manhã ele está alocado em um servidor com a <a href="http://pt.wikipedia.org/wiki/Crontab">crontab</a> configurada da seguinte maneira:</p>
<pre>
0 5 * * *  . /caminho_para_onde_ele_esta/rudaufc.sh
</pre>
<p><small>ps: leve em conta que o servidor está em um fuso horário diferente do Brasil.</small></p>
<p>Nessa versão o prato de cada dia está hardcoded no script, o que não é o ideal e faz com que semanalmente eu tenha que atualizar o script inserindo os pratos da semana manualmente. Eu espero que a próxima versão seja capaz de descobrir esses pratos e se atualizar sem nenhuma interferência.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2009/11/09/twitter-bot-rudaufc-versao-1/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Reading Twitter with JavaFX</title>
		<link>http://silveiraneto.net/2009/01/04/reding-twitter-with-javafx/</link>
		<comments>http://silveiraneto.net/2009/01/04/reding-twitter-with-javafx/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 22:56:55 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[jfx]]></category>
		<category><![CDATA[microblogging]]></category>
		<category><![CDATA[openjfx]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[Social Networking]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=2064</guid>
		<description><![CDATA[Twitter is a social network and micro-blogging service that allow you to create and read tweets, 140 characters text-based posts. It&#8217;s becoming a popular tool to keep in touch with your friends, coworkers, bloggers, etc. Here we&#8217;ll create a very simple application that show us tweets related with a given word. Twitter offers a very [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-2073 aligncenter" title="twitter bird" src="http://silveiraneto.net/wp-content/uploads/2009/01/twitter-bird.gif" alt="twitter bird" width="250" height="184" /></p>
<p><a title="Twitter Micro Blogging Service" href="http://twitter.com">Twitter</a> is a social network and micro-blogging service that allow you to create and read tweets, 140 characters text-based posts. It&#8217;s becoming a popular tool to keep in touch with your friends, coworkers, bloggers, etc. Here we&#8217;ll create a very simple application that show us tweets related with a given word.</p>
<p>Twitter offers a very simple and powerfull <a href="http://apiwiki.twitter.com/">REST API</a> which supports <a rel="nofollow" href="http://en.wikipedia.org/wiki/XML"><span>XML</span></a>, <a rel="nofollow" href="http://en.wikipedia.org/wiki/Json"><span>JSON</span></a>, and the <a rel="nofollow" href="http://en.wikipedia.org/wiki/RSS"><span>RSS</span></a> and <a rel="nofollow" href="http://en.wikipedia.org/wiki/Atom_%28standard%29">Atom</a> formats. As we are aiming just to read tweets we&#8217;ll use just the Search API.</p>
<p>We do that in three steps:</p>
<ol>
<li>Query Tweets</li>
<li>Parser the Atom result</li>
<li>Show tweets into a GUI</li>
</ol>
<p>Let&#8217;s see them in the order of dependence beetween them.</p>
<p><strong>Displaying a Tweet</strong></p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;">var gradient <span style="color: #339933;">=</span> LinearGradient <span style="color: #009900;">&#123;</span>
    startX<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0.0</span>,
    startY<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0.0</span>,
    endX<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0.0</span>,
    endY<span style="color: #339933;">:</span> <span style="color: #cc66cc;">150.0</span>
    proportional<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">false</span>
    stops<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>Stop <span style="color: #009900;">&#123;</span>offset<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0.0</span> color<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">DARKGRAY</span> <span style="color: #009900;">&#125;</span>,
        Stop <span style="color: #009900;">&#123;</span> offset<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1.0</span> color<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">BLACK</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Tweet <span style="color: #000000; font-weight: bold;">extends</span> CustomNode <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> var image<span style="color: #339933;">:</span> <span style="color: #003399;">Image</span>;
    <span style="color: #000000; font-weight: bold;">public</span> var username<span style="color: #339933;">:</span> <span style="color: #003399;">String</span>;
    <span style="color: #000000; font-weight: bold;">public</span> var message<span style="color: #339933;">:</span> <span style="color: #003399;">String</span>;
    <span style="color: #000000; font-weight: bold;">public</span> override function create<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> Node <span style="color: #009900;">&#123;</span>
        var txt <span style="color: #339933;">=</span> Text <span style="color: #009900;">&#123;</span>
            x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">65</span>  y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">35</span> wrappingWidth<span style="color: #339933;">:</span> <span style="color: #cc66cc;">150</span> fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">WHITE</span>
            content<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{message}&quot;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399;">Group</span> <span style="color: #009900;">&#123;</span>
            content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                <span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span>
                    width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">220</span> height<span style="color: #339933;">:</span> txt.<span style="color: #006633;">boundsInLocal</span>.<span style="color: #006633;">height</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">40</span>
                    arcHeight<span style="color: #339933;">:</span> <span style="color: #cc66cc;">10</span> arcWidth<span style="color: #339933;">:</span> <span style="color: #cc66cc;">10</span> fill<span style="color: #339933;">:</span> gradient
                <span style="color: #009900;">&#125;</span>,
                ImageView <span style="color: #009900;">&#123;</span>
                    x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">5</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">20</span> image<span style="color: #339933;">:</span> image
                <span style="color: #009900;">&#125;</span>,
                Text <span style="color: #009900;">&#123;</span>
                    x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">65</span>  y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">20</span> fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">BLACK</span> content<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{username} said&quot;</span>
                <span style="color: #009900;">&#125;</span>,
                txt
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>For example, <a title="P4bl0's Tweet" href="http://twitter.com/p4bl0/statuses/1095717367">this tweet</a> would become:</p>
<p style="text-align: center;"><img class="size-full wp-image-2070 aligncenter" title="tweet example" src="http://silveiraneto.net/wp-content/uploads/2009/01/tweet_example.png" alt="tweet example" width="220" height="100" /></p>
<p><strong>Parsing ATOM result</strong></p>
<p>In <a title="XML Sandwich JavaFX " href="http://silveiraneto.net/2008/12/25/parsing-xml-sandwich-with-javafx/">my last post about JavaFX</a> I showed how to parse XML documents (and make sandwiches) with JavaFX. Here we&#8217;ll use the Atom format, but use any other would be almost the same. Parsing XML or JSON documents with JavaFX is both very simple using the <a title="JavaFX API" href="http://java.sun.com/javafx/1/docs/api/javafx.data.pull/javafx.data.pull.PullParser.html">javafx.data.pull.PullParser</a> class.</p>
<p>A query output is a Atom XML document with several information. We are interested only in the fields that holds the avatar image, the message and the user name.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;">var tweets <span style="color: #339933;">=</span> VBox <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
def parser <span style="color: #339933;">=</span> PullParser <span style="color: #009900;">&#123;</span>
    var avatar;
    var firstname;
    var text;
    documentType<span style="color: #339933;">:</span> PullParser.<span style="color: #006633;">XML</span>;
&nbsp;
    onEvent<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span> <span style="color: #003399;">Event</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">type</span> <span style="color: #339933;">==</span> PullParser.<span style="color: #006633;">START_ELEMENT</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">qname</span>.<span style="color: #006633;">name</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;link&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">getAttributeValue</span><span style="color: #009900;">&#40;</span>QName<span style="color: #009900;">&#123;</span>name<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;rel&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;image&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    avatar <span style="color: #339933;">=</span> event.<span style="color: #006633;">getAttributeValue</span><span style="color: #009900;">&#40;</span>QName<span style="color: #009900;">&#123;</span>name<span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;href&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">type</span> <span style="color: #339933;">==</span> PullParser.<span style="color: #006633;">END_ELEMENT</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">qname</span>.<span style="color: #006633;">name</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;title&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    text <span style="color: #339933;">=</span> event.<span style="color: #006633;">text</span>;
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">qname</span>.<span style="color: #006633;">name</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#41;</span>and<span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">level</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                var names<span style="color: #339933;">:</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> event.<span style="color: #006633;">text</span>.<span style="color: #006633;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</span>;
                firstname <span style="color: #339933;">=</span> names<span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>;
                insert Tweet <span style="color: #009900;">&#123;</span>
                        image<span style="color: #339933;">:</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>
                            url<span style="color: #339933;">:</span> avatar
                        <span style="color: #009900;">&#125;</span>
                        message<span style="color: #339933;">:</span> text
                        username<span style="color: #339933;">:</span> firstname
                    <span style="color: #009900;">&#125;</span> into tweets.<span style="color: #006633;">content</span>;
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p><strong>Querying Tweets</strong></p>
<p>We can get Atom results through url queries like that:</p>
<ul>
<li>Tweets containing the word Beatles <a href="http://search.twitter.com/search.atom?q=Beatles">http://search.twitter.com/search.atom?q=Beatles</a></li>
<li>Tweets from the user Silveira <a href="http://search.twitter.com/search.atom?q=from%3ASilveira">http://search.twitter.com/search.atom?q=from%3ASilveira</a></li>
<li>Tweets to the user Silveira <a href="http://search.twitter.com/search.atom?q=to%3ASilveira">http://search.twitter.com/search.atom?q=to%3ASilveira</a></li>
<li>Tweets containing the hashtag #CEJUG <a href="http://search.twitter.com/search.atom?q=to%23CEJUG">http://search.twitter.com/search.atom?q=to%23CEJUG</a></li>
</ul>
<p>Notice that queries should be URL encoded. We will use a additional parameters <strong>&amp;rpp=4</strong> to receive<strong> </strong>only 4 results per page. To know more about search queries read the <a title="Twitter Search API" href="http://apiwiki.twitter.com/Search+API+Documentation">Search API Documentation</a>. We get these results as  <a title="Java API InputStream" href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html">InputStreams</a> making asynchronous HTTP requests using the <a title="JavaFX API" href="http://java.sun.com/javafx/1/docs/api/javafx.io.http/javafx.io.http.HttpRequest.html">javafx.io.http.HttpRequest</a> class, which it&#8217;s perfect to invoke   RESTful Web Services.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;">word <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Beatles&quot;</span>;
var request <span style="color: #339933;">=</span> HttpRequest <span style="color: #009900;">&#123;</span>
    location<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;http://search.twitter.com/search.atom?q={word}&amp;amp;rpp=4&quot;</span>;
    onInput<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span>stream<span style="color: #339933;">:</span> java.<span style="color: #006633;">io</span>.<span style="color: #003399;">InputStream</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        parser.<span style="color: #006633;">input</span> <span style="color: #339933;">=</span> stream;
        parser.<span style="color: #006633;">parse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
request.<span style="color: #006633;">enqueue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</pre>
</div>
</div>
<p><strong>Conclusion</strong></p>
<p>Here is the application running for the word &#8220;House&#8221;.</p>
<p style="text-align: center;"><img class="size-full wp-image-2074 aligncenter" title="twitter with javafx" src="http://silveiraneto.net/wp-content/uploads/2009/01/twitter_with_javafx.png" alt="twitter with javafx" width="220" height="458" /></p>
<p>Is not a complete Twitter client, as it&#8217;s not intended to be, but can show you how to handle a simple asynchronous call and handle Twitter documents. There&#8217;s already a few beta JavaFX Twitter clients like <a title="Tweetbox at Google Code" href="http://code.google.com/p/tweetbox/">Tweetbox</a> and <a title="TwitterFX at Project Kenai" href="http://projectkenai.com/projects/twitterfx">Twitterfx</a> and certanly others will appears.</p>
<p><strong>Download</strong></p>
<p>Sources and Netbeans project, <a href="http://silveiraneto.net/downloads/fxtwitter.tar.bz2">fxtwitter.tar.bz2</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2009/01/04/reding-twitter-with-javafx/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Achei uma utilidade pro Twitter!</title>
		<link>http://silveiraneto.net/2007/09/04/achei-uma-utilidade-pro-twitter/</link>
		<comments>http://silveiraneto.net/2007/09/04/achei-uma-utilidade-pro-twitter/#comments</comments>
		<pubDate>Wed, 05 Sep 2007 02:17:34 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[Celular]]></category>
		<category><![CDATA[microblogging]]></category>
		<category><![CDATA[miniblogging]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/2007/09/04/achei-uma-utilidade-pro-twitter/</guid>
		<description><![CDATA[Eu sempre achei o Twitter inútil e ridículo, mas hoje, depois de ter uma conta lá há anos finalmente eu consegui enxergar uma face útil nos mini-blogs como o twitter. Por uma série de motivos que envolvem: uma sacanagem de uma assistência técnica. eu ficar sem meu Nokia 6600 eu ficar puto e comprar um [...]]]></description>
			<content:encoded><![CDATA[<p>Eu sempre achei o Twitter inútil e ridículo, mas hoje, depois de ter uma conta lá há anos finalmente eu consegui enxergar uma face útil nos mini-blogs como o twitter.</p>
<p style="text-align: center"><img src="http://silveiraneto.net/wp-content/uploads/2007/09/garota_usando_celular.jpg" alt="Garota usando celular" /></p>
<p>Por uma série de motivos que envolvem:</p>
<ul>
<li>uma sacanagem de uma assistência técnica.</li>
<li>eu ficar sem meu Nokia 6600</li>
<li>eu ficar puto e comprar um Nokia 6610i usado de um gringo Norueguês.</li>
<li>eu finalmente conseguir configurar a porra do GPRS no celular</li>
</ul>
<p>Finalmente eu vi que eu posso ficar blogando/microblogando/twitando, como queiram, enquanto eu estou dentro do ônibus ou esperando na fila do dentista. Pronto, acabou a monotonia! Não tenho mais que ler as mesmas revistinhas da Turma da Mônica pela milésima vez ou ler aquelas Caras que tem em absolutamente qualquer consultório de qualquer coisa.</p>
<h3>E tem mais!</h3>
<p>Para a coisa fazer sentido eu estou colocando aqui na barra lateral direita uma seção mini-blog que é conectada com o RSS do <a href="http://twitter.com/silveira" title="Twitter">meu twitter</a>. Se a coisa ficar legal eu coloco um também no <a href="http://www.eupodiatamatando.com" title="Eu Podia Tá Matando">eupodiatamatando.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2007/09/04/achei-uma-utilidade-pro-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

