From 64ff4e2eeaf45f774566c99fa5c73f0f4070cff6 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Fri, 12 Nov 2010 12:41:19 -0500 Subject: [PATCH] INT-1557 fonosjed Twitter docs --- docs/src/reference/docbook/twitter.xml | 117 +++++++++++++++---------- 1 file changed, 73 insertions(+), 44 deletions(-) diff --git a/docs/src/reference/docbook/twitter.xml b/docs/src/reference/docbook/twitter.xml index 88086ab00f..5d0461d9c5 100644 --- a/docs/src/reference/docbook/twitter.xml +++ b/docs/src/reference/docbook/twitter.xml @@ -29,14 +29,12 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/twitter
- Twitter Connection and OAuth Configuration + Twitter OAuth Configuration + - Before using inbound or outbound Twitter adapters you must establish secured Twitter connection. This connection object - could be shared by all twitter adapters connected to a particular account. - - - Twitter uses OAuth - an authentication protocol that allows users to approve application to act on their behalf without + Twitter API allows for both authenticated and anonymous operations. For authenticated operations Twitter uses OAuth + - an authentication protocol that allows users to approve application to act on their behalf without sharing their password. More information can be found at http://oauth.net/ or in this article http://hueniverse.com/oauth/ from Hueniverse. Please also see OAuth FAQ for more information about OAuth and Twitter. @@ -64,21 +62,32 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/twitter + +
+
+ Twitter Template + - Twitter Connection - + Spring Integration uses the same familiar template pattern to interact with Twitter. Since current Twitter support + is based on Twitter4J API and we provide Twiter4JTemplate. + For anonymous operation (e.g., search) you don't have to define Twitter4JTemplate explicitly, since the default + instance of it will be created and injected into the endpoint. However, for authenticated operation + (e.g., update status, send direct message etc.) you must configure Twitter4JTemplate as a bean and + inject it explicitly into the endpoint. Below is a sample configuration of Twitter4JTemplate: - - Spring Integration provides a convenient namespace configuration to define Twitter Connection. As you can see form the - configuration below you configure Twitter connection via twitter-connection element while providing - OAuth attributes filling them with values you have obtained in the previous step. - ]]> + + + + + +]]> The values above are not real + + As you can see form the configuration above all we need to do is to provide + OAuth attributes as constructor arguments filling them with values you have obtained in the previous step. + The order of constructor arguments is: 1) consumerKey; 2) consumerSecret; + 3) accessToken; 4) accessTokenSecret; @@ -95,11 +104,12 @@ and configuring a property-placeholder pointing to he above propert -]]> + + + + + +]]>
@@ -110,8 +120,8 @@ and configuring a property-placeholder pointing to he above propert twitter messages - tweets - Current release of Spring Integration provides support for receiving Public Messages, - Direct Messages as well as Mention Messages + Current release of Spring Integration provides support for receiving tweets as Public Messages, + Direct Messages, Mention Messages as well as perform Searches Every Inbound Twitter Channel Adapter is a Polling consumer which means you have to provide a poller @@ -120,7 +130,7 @@ and configuring a property-placeholder pointing to he above propert it here: Rate Limiting . In the nutshell Rate Limiting is the way Twitter manages how often an application can poll for updates. Luckily for you you don't have to worry about it since the special Rate limit aware polling thread is created when any Twitter adapter is started. This thread will - poll Messages (Tweets) from the Twitter account at the rate allowed by Twitter at the time (it may change after every poll). The Tweets + poll Messages (Tweets) from the Twitter account at the rate allowed by Twitter at the time (it may change after every poll). The latest Tweet timestamp will be stored in the instance of the org.springframework.integration.store.MetadataStore which is a strategy interface designed for storing various types of metadata (e.g., last retrieved tweet) to help components such as Twitter to deal with duplicates. By default, Spring Integration will look for a bean of type org.springframework.integration.store.MetadataStore @@ -135,45 +145,64 @@ and configuring a property-placeholder pointing to he above propert The Poller that is configured as part of the any Inbound Twitter Adapter (see below) will simply poll from this MetadataStore
- Inbound Update Channel Adapter + Inbound Message Channel Adapter This adapter allows you to receive updates from everyone you follow. - + -]]> +]]>
- Inbound Direct Message Channel Adapter + Direct Inbound Message Channel Adapter This adapter allows you to receive Twitter Messages that were sent directly to you - + -]]> +]]>
- Inbound Mention Message Channel Adapter + Mentions Inbound Message Channel Adapter This adapter allows you to receive Twitter Messages that Mention you via @user - + -]]> +]]> + +
+ + As you can see the configuration of all of these adapters is very similar to other inbound adapters with one exception. - Each one needs to be injected with the twitter-connection. Once configured the Twitter Messages would be + Some may need to be injected with the twitter-template. Once configured the Twitter Messages would be encapsulated into a Spring Integration Message and sent to a channel specified via channel attribute. - Currently the Payload of the Message is twitter4j.DirectMessage for Inbound Direct Message Channel Adapter - or twitter4j.Status for Inbound Update Channel Adapter and - Inbound Mention Message Channel Adapter. + Currently the Payload type of any Message is org.springframework.integration.twitter.core.Tweet + which is very similar to the object with the same name in Spring Social. As we migrate to Spring Social + we'll be depending on their API and some of the artifacts that ar currently in use will be obsolete, however we've already + made sure that the impact of such migration is minimal by alignning our API with the curent state (at the time of writing) + of Spring Social - For example; to get the text from the twitter4j.DirectMessage or twitter4j.Status - simply invoke getText() method. For more information please refer to Twitter4J API + To get the text from the org.springframework.integration.twitter.core.Tweet + simply invoke getText() method. @@ -194,8 +223,8 @@ The Poller that is configured as part of the any Inbound Twitter Adapter (see be This adapter allows you to send regular status updates by simply sending a Message to a channel identified via channel attribute. - ]]> - The only extra configuration that is required for this adapter is twitter-connection + ]]> + The only extra configuration that is required for this adapter is twitter-template @@ -204,8 +233,8 @@ The Poller that is configured as part of the any Inbound Twitter Adapter (see be This adapter allows you to send Direct Twitter Messages (i.e., @user) by simply sending a Message to a channel identified via channel attribute. - ]]> - The only extra configuration that is required for this adapter is twitter-connection + ]]> + The only extra configuration that is required for this adapter is twitter-template