camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Twitter
Date Wed, 02 Jan 2013 13:03:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/Twitter">Twitter</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (12)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >Rather than the endpoints returning
a List through one single route exchange, camel-twitter creates one route exchange per returned
object.  As an example, if &quot;timeline/home&quot; results in five statuses, the
route will be executed five times (one for each Status). <br>{div:class=confluenceTableSmall}
<br></td></tr>
            <tr><td class="diff-changed-lines" >|| Endpoint || Context || Body
Type || <span class="diff-added-words"style="background-color: #dfd;">Notice ||</span>
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|
streaming/filter | event, polling | twitter4j.Status | | <br></td></tr>
            <tr><td class="diff-unchanged" >| directmessage | direct, polling
| twitter4j.DirectMessage | |
| search | direct, polling | twitter4j.Tweet | | <br></td></tr>
            <tr><td class="diff-changed-lines" >| <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">streaming/filter</span>
<span class="diff-added-words"style="background-color: #dfd;">streaming/sample</span>
| event, polling | twitter4j.Status | <span class="diff-added-words"style="background-color:
#dfd;">|</span> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">|
streaming/sample | event, polling | twitter4j.Status | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|
timeline/home | direct, polling | twitter4j.Status | | <br></td></tr>
            <tr><td class="diff-changed-lines" >| <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">timeline/home</span>
<span class="diff-added-words"style="background-color: #dfd;">timeline/mentions</span>
| direct, polling | twitter4j.Status | <span class="diff-added-words"style="background-color:
#dfd;">|</span> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|
timeline/public | direct, polling | twitter4j.Status | @deprecated. Use timeline/home or direct/home
instead. Removed from *Camel 2.11* onwards. | <br></td></tr>
            <tr><td class="diff-changed-lines" >| <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">timeline/mentions</span>
<span class="diff-added-words"style="background-color: #dfd;">timeline/retweetsofme</span>
| direct, polling | twitter4j.Status | <span class="diff-added-words"style="background-color:
#dfd;">|</span> <br></td></tr>
            <tr><td class="diff-changed-lines" >| <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">timeline/public</span>
<span class="diff-added-words"style="background-color: #dfd;">timeline/user</span>
| direct, polling | twitter4j.Status | <span class="diff-added-words"style="background-color:
#dfd;">|</span> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">|
timeline/retweetsofme | direct, polling | twitter4j.Status | <br>| timeline/user | direct,
polling | twitter4j.Status | <br></td></tr>
            <tr><td class="diff-changed-lines" >| trends/daily | *Camel 2.10.1:*
direct, polling | twitter4j.Status | <span class="diff-added-words"style="background-color:
#dfd;">@deprecated. Removed from Camel 2.11 onwards. |</span> <br></td></tr>
            <tr><td class="diff-changed-lines" >| trends/weekly | *Camel 2.10.1:*
direct, polling | twitter4j.Status | <span class="diff-added-words"style="background-color:
#dfd;">@deprecated. Removed from Camel 2.11 onwards. |</span> <br></td></tr>
            <tr><td class="diff-unchanged" >{div} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="Twitter-Twitter"></a>Twitter</h2>
<p><b>Available as of Camel 2.10</b></p>

<p>The Twitter component enables the most useful features of the Twitter API by encapsulating
<a href="http://twitter4j.org/" class="external-link" rel="nofollow">Twitter4J</a>.
It allows direct, polling, or event-driven consumption of timelines, users, trends, and direct
messages. Also, it supports producing messages as status updates or direct messages.</p>

<p>Twitter now requires the use of OAuth for all client application authentication.
 In order to use camel-twitter with your account, you'll need to create a new application
within Twitter at <a href="https://dev.twitter.com/apps/new" class="external-link" rel="nofollow">https://dev.twitter.com/apps/new</a>
and grant the application access to your account. Finally, generate your access token and
secret.</p>

<p>Maven users will need to add the following dependency to their pom.xml for this component:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-twitter<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>${camel-version}<span
class="code-tag">&lt;/version&gt;</span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<h3><a name="Twitter-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
twitter:<span class="code-comment">//[endpoint]?[options]</span>
</pre>
</div></div>

<h3><a name="Twitter-TwitterComponent%3A"></a>TwitterComponent:</h3>

<p>The twitter component can be configured with the Twitter account settings which is
mandatory to configure before using.<br/>
You can also configure these options directly in the endpoint.</p>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Option </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> consumerKey </td>
<td class='confluenceTd'> The consumer key </td>
</tr>
<tr>
<td class='confluenceTd'> consumerSecret </td>
<td class='confluenceTd'> The consumer secret </td>
</tr>
<tr>
<td class='confluenceTd'> accessToken </td>
<td class='confluenceTd'> The access token </td>
</tr>
<tr>
<td class='confluenceTd'> accessTokenSecret </td>
<td class='confluenceTd'> The access token secret </td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="Twitter-ConsumerEndpoints%3A"></a>Consumer Endpoints:</h3>
<p>Rather than the endpoints returning a List through one single route exchange, camel-twitter
creates one route exchange per returned object.  As an example, if "timeline/home" results
in five statuses, the route will be executed five times (one for each Status).</p>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Endpoint </th>
<th class='confluenceTh'> Context </th>
<th class='confluenceTh'> Body Type </th>
<th class='confluenceTh'> Notice </th>
</tr>
<tr>
<td class='confluenceTd'> directmessage </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> twitter4j.DirectMessage </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> search </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> twitter4j.Tweet </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> streaming/filter </td>
<td class='confluenceTd'> event, polling </td>
<td class='confluenceTd'> twitter4j.Status </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> streaming/sample </td>
<td class='confluenceTd'> event, polling </td>
<td class='confluenceTd'> twitter4j.Status </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> timeline/home </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> twitter4j.Status </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> timeline/mentions </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> twitter4j.Status </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> timeline/public </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> twitter4j.Status </td>
<td class='confluenceTd'> @deprecated. Use timeline/home or direct/home instead. Removed
from <b>Camel 2.11</b> onwards. </td>
</tr>
<tr>
<td class='confluenceTd'> timeline/retweetsofme </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> twitter4j.Status </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> timeline/user </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> twitter4j.Status </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> trends/daily </td>
<td class='confluenceTd'> <b>Camel 2.10.1:</b> direct, polling </td>
<td class='confluenceTd'> twitter4j.Status </td>
<td class='confluenceTd'> @deprecated. Removed from Camel 2.11 onwards. </td>
</tr>
<tr>
<td class='confluenceTd'> trends/weekly </td>
<td class='confluenceTd'> <b>Camel 2.10.1:</b> direct, polling </td>
<td class='confluenceTd'> twitter4j.Status </td>
<td class='confluenceTd'> @deprecated. Removed from Camel 2.11 onwards. </td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="Twitter-ProducerEndpoints%3A"></a>Producer Endpoints:</h3>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Endpoint </th>
<th class='confluenceTh'> Body Type </th>
</tr>
<tr>
<td class='confluenceTd'> directmessage </td>
<td class='confluenceTd'> String </td>
</tr>
<tr>
<td class='confluenceTd'> search </td>
<td class='confluenceTd'> List&lt;twitter4j.Tweet&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> timeline/user </td>
<td class='confluenceTd'> String </td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="Twitter-URIOptions"></a>URI Options</h3>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> type </td>
<td class='confluenceTd'> <tt>direct</tt> </td>
<td class='confluenceTd'> direct, event, or polling </td>
</tr>
<tr>
<td class='confluenceTd'> delay </td>
<td class='confluenceTd'> <tt>60</tt> </td>
<td class='confluenceTd'> in seconds </td>
</tr>
<tr>
<td class='confluenceTd'> consumerKey </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Consumer Key. Can also be configured on the <tt>TwitterComponent</tt>
level instead. </td>
</tr>
<tr>
<td class='confluenceTd'> consumerSecret </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Consumer Secret. Can also be configured on the <tt>TwitterComponent</tt>
level instead. </td>
</tr>
<tr>
<td class='confluenceTd'> accessToken </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Access Token. Can also be configured on the <tt>TwitterComponent</tt>
level instead. </td>
</tr>
<tr>
<td class='confluenceTd'> accessTokenSecret </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Access Token Secret. Can also be configured on the <tt>TwitterComponent</tt>
level instead. </td>
</tr>
<tr>
<td class='confluenceTd'> user </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Username, used for user timeline consumption, direct message
production, etc. </td>
</tr>
<tr>
<td class='confluenceTd'> locations</td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> 'lat,lon;lat,lon;...' Bounding boxes, created by pairs of
lat/lons.  Can be used for streaming/filter </td>
</tr>
<tr>
<td class='confluenceTd'> keywords</td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> 'foo1,foo2,foo3...' Can be used for search and streaming/filter
</td>
</tr>
<tr>
<td class='confluenceTd'> userIds</td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> 'username,username...' Can be used for streaming/filter </td>
</tr>
<tr>
<td class='confluenceTd'> filterOld </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> Filter out old tweets, that has previously been polled. This
state is stored in memory only, and based on last tweet id. </td>
</tr>
</tbody></table>
</div>
</div>


<h3><a name="Twitter-Messagebody"></a>Message body</h3>
<p>All message bodies utilize objects provided by the Twitter4J API.</p>


<h3><a name="Twitter-Usecases"></a>Use cases</h3>

<h4><a name="Twitter-TocreateastatusupdatewithinyourTwitterprofile%2CsendthisproduceraStringbody."></a>To
create a status update within your Twitter profile, send this producer a String body.</h4>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:foo"</span>)
  .to("twitter:<span class="code-comment">//timeline/user?consumerKey=[s]&amp;consumerSecret=[s]&amp;accessToken=[s]&amp;accessTokenSecret=[s]);</span>
</pre>
</div></div>
<h4><a name="Twitter-Topoll%2Cevery5sec.%2Callstatusesonyourhometimeline%3A"></a>To
poll, every 5 sec., all statuses on your home timeline:</h4>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"twitter:<span class="code-comment">//timeline/home?type=polling&amp;delay=5&amp;consumerKey=[s]&amp;consumerSecret=[s]&amp;accessToken=[s]&amp;accessTokenSecret=[s]"</span>)
</span>  .to(<span class="code-quote">"bean:blah"</span>);
</pre>
</div></div>
<h4><a name="Twitter-Tosearchforallstatuseswiththekeyword%27camel%27%3A"></a>To
search for all statuses with the keyword 'camel':</h4>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"twitter:<span class="code-comment">//search?type=direct&amp;keywords=camel&amp;consumerKey=[s]&amp;consumerSecret=[s]&amp;accessToken=[s]&amp;accessTokenSecret=[s]"</span>)
</span>  .to(<span class="code-quote">"bean:blah"</span>);
</pre>
</div></div>

<h4><a name="Twitter-Searchingusingaproducerwithstatickeywords"></a>Searching
using a producer with static keywords</h4>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:foo"</span>)
  .to(<span class="code-quote">"twitter:<span class="code-comment">//search?keywords=camel&amp;consumerKey=[s]&amp;consumerSecret=[s]&amp;accessToken=[s]&amp;accessTokenSecret=[s]"</span>);</span>
</pre>
</div></div>

<h4><a name="Twitter-Searchingusingaproducerwithdynamickeywordsfromheader"></a>Searching
using a producer with dynamic keywords from header</h4>
<p>In the bar header we have the keywords we want to search, so we can assign this value
to the <tt>CamelTwitterKeywords</tt> header.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"direct:foo"</span>)
  .setHeader(<span class="code-quote">"CamelTwitterKeywords"</span>, header(<span
class="code-quote">"bar"</span>))
  .to(<span class="code-quote">"twitter:<span class="code-comment">//search?consumerKey=[s]&amp;consumerSecret=[s]&amp;accessToken=[s]&amp;accessTokenSecret=[s]"</span>);</span>
</pre>
</div></div>

<h3><a name="Twitter-Example"></a>Example</h3>
<p>See also the <a href="/confluence/display/CAMEL/Twitter+Websocket+Example" title="Twitter
Websocket Example">Twitter Websocket Example</a>.</p>

<h3><a name="Twitter-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

<ul class="alternate" type="square">
	<li><a href="/confluence/display/CAMEL/Twitter+Websocket+Example" title="Twitter
Websocket Example">Twitter Websocket Example</a></li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Twitter">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=27837225&revisedVersion=12&originalVersion=11">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Twitter?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message