INT-1552 doc polishing

This commit is contained in:
Mark Fisher
2010-11-22 15:54:20 -05:00
parent ee2ecf682f
commit 109c8c559e

View File

@@ -1,25 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<chapter xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="twitter"
xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Twitter Adapter</title>
<para>
Spring Integration provides support for interacting with Twitter via Twitter adapters. With Twitter adapters you can both
receive and send Twitter messages.
Spring Integration provides support for interacting with Twitter. With the Twitter adapters you can both
receive and send Twitter messages.
</para>
<section id="twitter-intro">
<title>Introduction</title>
<para>
Twitter is a social networking and microblogging service that enables its users to send and read messages known as tweets.
Twitter is a social networking and micro-blogging service that enables its users to send and read messages known as tweets.
Tweets are text-based posts of up to 140 characters displayed on the author's profile page and delivered to the author's
subscribers who are known as followers.
</para>
<para>
<important>
Current Twitter support is based on <link linkend="http://twitter4j.org/en/index.html">Twitter4J API</link>,
however future version will be changed to use <link linkend="https://jira.springframework.org/browse/SOCIAL">Spring Social</link>
Current Twitter support is based on the <link linkend="http://twitter4j.org/en/index.html">Twitter4J API</link>.
However, future versions will be changed to use the <link linkend="https://jira.springframework.org/browse/SOCIAL">Spring Social</link>
project as it is nearing its first release at the time of writing.
</important>
</para>
<para>
Spring Integration provides a convenient namespace configuration to define Twitter artifacts.
<programlisting language="xml"><![CDATA[xmlns:twitter="http://www.springframework.org/schema/integration/twitter"
@@ -31,17 +34,16 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/twitter
<section id="twitter-oauth">
<title>Twitter OAuth Configuration</title>
<para>
Twitter API allows for both authenticated and anonymous operations. For authenticated operations Twitter uses OAuth
The 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 <link linkend="http://oauth.net/">http://oauth.net/</link> or
in this article <link linkend="http://hueniverse.com/oauth/">http://hueniverse.com/oauth/</link> from Hueniverse.
Please also see <link linkend="http://dev.twitter.com/pages/oauth_faq">OAuth FAQ</link> for more information about OAuth and Twitter.
</para>
<para>
In order to use OAuth authentication/authorization with Twitter you must create new Application on Twitter Developers site.
Follow the directions below to create a new application and obtain consumer keys and access token:
In order to use OAuth authentication/authorization with Twitter you must create new Application on the Twitter Developers site.
Follow the directions below to create a new application and obtain consumer keys and an access token:
</para>
<para>
<itemizedlist>
@@ -84,7 +86,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/twitter
</bean>]]></programlisting>
<note>The values above are not real</note>
As you can see form the configuration above all we need to do is to provide
As you can see from the configuration above all we need to do is to provide
OAuth <code>attributes</code> as constructor arguments filling them with values you have obtained in the previous step.
The order of constructor arguments is: 1) <code>consumerKey</code>; 2) <code>consumerSecret</code>;
3) <code>accessToken</code>; 4) <code>accessTokenSecret</code>;
@@ -120,20 +122,20 @@ and configuring a <code>property-placeholder</code> pointing to he above propert
<link linkend="http://support.twitter.com/groups/31-twitter-basics/topics/109-tweets-messages/articles/119138-types-of-tweets-and-where-they-appear">twitter messages - tweets</link>
</para>
<para>
Current release of Spring Integration provides support for receiving tweets as <emphasis>Public Messages</emphasis>,
The current release of Spring Integration provides support for receiving tweets as <emphasis>Public Messages</emphasis>,
<emphasis>Direct Messages</emphasis>, <emphasis>Mention Messages</emphasis> as well as perform Searches
</para>
<para>
Every Inbound Twitter Channel Adapter is a <emphasis>Polling consumer</emphasis> which means you have to provide a poller
configuration. However, one important thing you must understand with regard to Twitter since its inner-workings are slightly
different then any other poling consumer. Twitter defines a concept of Rate Limiting. You can read more about
it here: <link linkend="http://dev.twitter.com/pages/rate-limiting">Rate Limiting</link> . In the nutshell Rate Limiting
it here: <link linkend="http://dev.twitter.com/pages/rate-limiting">Rate Limiting</link>. In a 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 we are handling it internally polling for Messages (Tweets) from the Twitter account at the rate allowed by Twitter.
</para>
<para>
Another issue that we need to worry about is handling of the duplicates. The same adapter (e.g., Search or Timeline Update)
while polling on Twitter may receive the same values back. For example if you keep searching on Twitter with the same search
Another issue that we need to worry about is handling of duplicates. The same adapter (e.g., Search or Timeline Update)
while polling on Twitter may receive the same values more than once. For example if you keep searching on Twitter with the same search
criteria you'll end up with the same set of tweets unless some other new tweet that matches your search criteria was posted
in between your searches. In that situation you'll get all the tweets you had before plus the new one. But what you really
want is only the new tweet. Spring Integration provides an elegant mechanism for handling these situations.
@@ -202,8 +204,8 @@ The Poller that is configured as part of the any Inbound Twitter Adapter (see be
encapsulated into a Spring Integration Message and sent to a channel specified via <code>channel</code> attribute.
Currently the Payload type of any Message is <classname>org.springframework.integration.twitter.core.Tweet</classname>
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)
we'll be depending on their API and some of the artifacts that are currently in use will be obsolete, however we've already
made sure that the impact of such migration is minimal by aligning our API with the current state (at the time of writing)
of Spring Social
</para>
<para>
@@ -246,7 +248,7 @@ The Poller that is configured as part of the any Inbound Twitter Adapter (see be
<para>
<important>Twitter does not allow you to post duplicate Messages. This is a common problem during testing when
the same code works the first time but doesn't work the second time,so make sure to change the content of the Message.
One thing that works good for testing is appent timestamp to the end of the message.
One thing that works good for testing is to append a timestamp to the end of the message.
</important>
</para>
</section>