25.02.2015 Views

Introducing Spring Framework

Introducing Spring Framework

Introducing Spring Framework

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 17<br />

Be Social and Go Mobile<br />

Nowadays most applications expose some connectivity to social networks like Facebook, Twitter, and LinkedIn in<br />

order to allow users to post status messages or to get the latest news. Other applications offer some enhancements like<br />

connectivity to DropBox for storage or for sharing pictures and videos to Instagram or Tumblr.<br />

In this chapter, you are going to use Twitter to tweet about new documents that you have created in your<br />

repository. But how are you going to do this? The answer is easy. By using <strong>Spring</strong>, of course!<br />

Using <strong>Spring</strong> Social<br />

The <strong>Spring</strong> <strong>Framework</strong> offers an extension called <strong>Spring</strong> Social that helps you to connect your applications with<br />

SaaS (Software-as-a-Service) API providers like Facebook, Twitter, LinkedIn, GitHub, and Tripit. There are also some<br />

community projects that use the <strong>Spring</strong> Social core module to connect to more of these providers like DropBox,<br />

Google, Tumblr, Instagram, and others.<br />

The key features that <strong>Spring</strong> Social provides are the following:<br />

• Bindings for APIs such as Facebook, Twitter, LinkedIn, Github, and Tripit.<br />

• A simple way to connect a local user account to hosted provider accounts.<br />

• Controllers that help with the authorization and authentication process.<br />

• A high-level API that is easy to use.<br />

So let’s start integrating Twitter into your <strong>Spring</strong> application, My Documents.<br />

<strong>Spring</strong> Social Twitter<br />

<strong>Spring</strong> Social offers several modules, for example <strong>Spring</strong> Social Core, <strong>Spring</strong> Social FaceBook, and <strong>Spring</strong> Social<br />

Twitter. You will be using <strong>Spring</strong> Social Twitter, which offers an API binding for Twitter’s REST API.<br />

In order to interact with the REST API that Twitter offers, first it is necessary to have a Twitter account and then<br />

you need to register an application with Twitter. I’m assuming that you already have a Twitter account, so the next<br />

section will guide you through registering your application in Twitter. Why is this step necessary? Well, in order to<br />

perform actions with the Twitter API like post an update, read posts, getting all your friends’ posts, etc., it is necessary<br />

to have some access keys to establish a secure and trustworthy communication between your application and<br />

Twitter’s REST API.<br />

231

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!