Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Maven users will need to add the following dependency to their pom.xml for this component:

Code Block
xml
xml

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-twitter</artifactId>
    <version>${camel-version}</version>
</dependency>

URI format

Code Block

twitter://endpoint[?options]

...

Wiki Markup
{div:class=confluenceTableSmall}
|| Name || Default Value || Description ||
| type | {{direct}} | direct, event, or polling |
| delay | {{60}} | in seconds |
| consumerKey | {{null}} | Consumer Key. Can also be configured on the {{TwitterComponent}} level instead. |
| consumerSecret | {{null}} | Consumer Secret. Can also be configured on the {{TwitterComponent}} level instead. |
| accessToken | {{null}} | Access Token. Can also be configured on the {{TwitterComponent}} level instead. |
| accessTokenSecret | {{null}} | Access Token Secret. Can also be configured on the {{TwitterComponent}} level instead. |
| user | {{null}} | Username, used for user timeline consumption, direct message production, etc. |
| locations| {{null}} | 'lat,lon;lat,lon;...' Bounding boxes, created by pairs of lat/lons.  Can be used for streaming/filter |
| keywords| {{null}} | 'foo1,foo2,foo3...' Can be used for search and streaming/filter. See [Advanced search|https://support.twitter.com/articles/71577-using-advanced-search] for keywords syntax for searching with for example OR. |
| userIds| {{null}} | 'username,username...' Can be used for streaming/filter |
| filterOld | {{true}} | Filter out old tweets, that has previously been polled. This state is stored in memory only, and based on last tweet id. *Since Camel 2.11.0* The search producer supports this option |
| sinceId | {{1}} | *Camel 2.11.0:* The last tweet id which will be used for pulling the tweets. It is useful when the camel route is restarted after a long running.|
| lang | {{null}} | *Camel 2.11.0:* The lang string [ISO_639-1|http://en.wikipedia.org/wiki/ISO_639-1] which will be used for searching |
| count | {{null}} | *Camel 2.11.0:* Limiting number of results per page. |
| numberOfPages | {{1}} | *Camel 2.11.0:* The number of pages result which you want camel-twitter to consume. |
| httpProxyHost | {{null}} | *Camel 2.12.3:* The http proxy host which can be used for the camel-twitter. |
| httpProxyPort | {{null}} | *Camel 2.12.3:* The http proxy port which can be used for the camel-twitter. |
| httpProxyUser | {{null}} | *Camel 2.12.3:* The http proxy user which can be used for the camel-twitter. |
| httpProxyPassword | {{null}} | *Camel 2.12.3:* The http proxy password which can be used for the camel-twitter. |
{div}

Message header

Wiki Markup
{div:class=confluenceTableSmall}
|| Name || Description ||
|{{CamelTwitterKeywords}}|This header is used by the search producer to change the search key words dynamically.|
|{{CamelTwitterSearchLanguage}}| *Camel 2.11.0:* This header can override the option of {{lang}} which set the search language for the search endpoint dynamically|
|{{CamelTwitterCount}}|*Camel 2.11.0* This header can override the option of {{count}} which sets the max twitters that will be returned.|
|{{CamelTwitterNumberOfPages}}|*Camel 2.11.0* This header can converrid the option of {{numberOfPages}} which sets how many pages we want to twitter returns.|
{div}

...

To create a status update within your Twitter profile, send this producer a String body.

Code Block

from("direct:foo")
  .to("twitter://timeline/user?consumerKey=[s]&consumerSecret=[s]&accessToken=[s]&accessTokenSecret=[s]);

To poll, every 5 sec., all statuses on your home timeline:

Code Block

from("twitter://timeline/home?type=polling&delay=5&consumerKey=[s]&consumerSecret=[s]&accessToken=[s]&accessTokenSecret=[s]")
  .to("bean:blah");

To search for all statuses with the keyword 'camel':

Code Block

from("twitter://search?type=direct&keywords=camel&consumerKey=[s]&consumerSecret=[s]&accessToken=[s]&accessTokenSecret=[s]")
  .to("bean:blah");

Searching using a producer with static keywords

Code Block

from("direct:foo")
  .to("twitter://search?keywords=camel&consumerKey=[s]&consumerSecret=[s]&accessToken=[s]&accessTokenSecret=[s]");

...

In the bar header we have the keywords we want to search, so we can assign this value to the CamelTwitterKeywords header.

Code Block

from("direct:foo")
  .setHeader("CamelTwitterKeywords", header("bar"))
  .to("twitter://search?consumerKey=[s]&consumerSecret=[s]&accessToken=[s]&accessTokenSecret=[s]");

...

See also the Twitter Websocket Example.

Include Page
Endpoint See Also
Endpoint See Also