Simple Spring Social for Twitter Friends

DZone 's Guide to

Simple Spring Social for Twitter Friends

· Java Zone ·
Free Resource

The Spring Social project provides us developers with an easy way to interact with Twitter, Facebook, LinkedIn & TripIt via the familiar Template objects we have used. Spring has provided Templates for convenient interaction with JDBC, REST, Hibernate, JNDI, and more.

One of the simplest social media calls is to lookup someone’s Twitter friends with the TwitterTemplate.

1. Add the Spring Social project dependency to the pom.xml file


2. Add the Spring Milestone Repository repository to the pom.xml file

<name>Spring Maven Milestone Repository</name>

3. Create the TwitterTemplate, and ask for friends

TwitterTemplate twitterTemplate = new TwitterTemplate();
List<String> friends = twitterTemplate.getFriends("chariotsolution");

for (String friend : friends) {
System.out.println("Friend: " + friend);

4. Use the code above anywhere in your application

In the next blog, I will cover how to use Open Authentication (OAuth) to perform more Twitter operations.

From http://gordondickens.com/wordpress/2011/01/03/simple-spring-social-for-twitter-friends/


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}