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 Fri, 03 Feb 2012 00:11: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>added</b> by             <a href="https://cwiki.apache.org/confluence/display/~bibryam">Bilgin
Ibryam</a>
    </h4>
         <br/>
    <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>Since all message bodies rely on Twitter4J objects, the additional Twitter4J dependencies
will be necessary within your project. Maven users will need to add the following dependency
to their <tt>pom.xml</tt> 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>x.x.x<span class="code-tag">&lt;/version&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- use the same
version as your Camel core version --&gt;</span></span>
<span class="code-tag">&lt;/dependency&gt;</span>

<span class="code-tag">&lt;dependency&gt;</span>
	<span class="code-tag">&lt;groupId&gt;</span>org.twitter4j<span class="code-tag">&lt;/groupId&gt;</span>
	<span class="code-tag">&lt;artifactId&gt;</span>twitter4j-core<span
class="code-tag">&lt;/artifactId&gt;</span>
	<span class="code-tag">&lt;version&gt;</span>${twitter4j-version}<span
class="code-tag">&lt;/version&gt;</span>
<span class="code-tag">&lt;/dependency&gt;</span>

<span class="code-tag">&lt;dependency&gt;</span>
	<span class="code-tag">&lt;groupId&gt;</span>org.twitter4j<span class="code-tag">&lt;/groupId&gt;</span>
	<span class="code-tag">&lt;artifactId&gt;</span>twitter4j-stream<span
class="code-tag">&lt;/artifactId&gt;</span>
	<span class="code-tag">&lt;version&gt;</span>${twitter4j-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-URIOptions"></a>URI Options</h3>
<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'> direct </td>
<td class='confluenceTd'> direct, event, or polling </td>
</tr>
<tr>
<td class='confluenceTd'> delay </td>
<td class='confluenceTd'> 60 </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 </td>
</tr>
<tr>
<td class='confluenceTd'> *consumerSecret </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Consumer Secret </td>
</tr>
<tr>
<td class='confluenceTd'> *accessToken </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Access Token </td>
</tr>
<tr>
<td class='confluenceTd'> *accessTokenSecret </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> Access Token Secret </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'> keywords</td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> 'lat,lon;lat,lon;...' Can be used for 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>
</tbody></table>
</div>


<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Notes</b><br
/>Options: (* = required). Message body: All message bodies utilize objects provided by
the Twitter4J library.</td></tr></table></div>

<h4><a name="Twitter-ConsumerEndpoints%3A"></a>Consumer Endpoints:</h4>
<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>
</tr>
<tr>
<td class='confluenceTd'> directmessage </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> List&lt;twitter4j.DirectMessage&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> search </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> List&lt;twitter4j.Tweet&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> streaming/filter </td>
<td class='confluenceTd'> event, polling </td>
<td class='confluenceTd'> List&lt;twitter4j.Status&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> streaming/sample </td>
<td class='confluenceTd'> event, polling </td>
<td class='confluenceTd'> event: twitter4j.Status, polling: List&lt;twitter4j.Status&gt;
</td>
</tr>
<tr>
<td class='confluenceTd'> timeline/home </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> List&lt;twitter4j.Status&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> timeline/mentions </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> List&lt;twitter4j.Status&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> timeline/public </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> List&lt;twitter4j.Status&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> timeline/retweetsofme </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> List&lt;twitter4j.Status&gt; </td>
</tr>
<tr>
<td class='confluenceTd'> timeline/user </td>
<td class='confluenceTd'> direct, polling </td>
<td class='confluenceTd'> List&lt;twitter4j.Status&gt; </td>
</tr>
</tbody></table>
</div>
</div>

<h4><a name="Twitter-ProducerEndpoints%3A"></a>Producer Endpoints:</h4>
<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'> timeline/user </td>
<td class='confluenceTd'> String </td>
</tr>
</tbody></table>
</div>
</div>

<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">
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">
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>
</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">
twitter:<span class="code-comment">//search?type=direct&amp;keywords=camel&amp;consumerKey=[s]&amp;consumerSecret=[s]&amp;accessToken=[s]&amp;accessTokenSecret=[s]</span>
</pre>
</div></div>
<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>

    </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/display/CAMEL/Twitter?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message