Skip to content

Instantly share code, notes, and snippets.

@cfalzone cfalzone/gist:5356502

Last active Dec 16, 2015
Embed
What would you like to do?
Just an example using Twiter4J in a Velocity ViewTool
public class TwitterTool implements ViewTool {
private Twitter twitter;
private boolean inited = false;
public void init(Object initData) {
try {
twitter = new TwitterFactory().getInstance();
inited = true;
} catch (Exception e) {
Logger.error(this, "Error getting twitter instance", e);
inited = false;
}
}
public List<Status> getTimeline(String user) {
if(inited) {
try {
return List<Status> statuses = twitter.getUserTimeline(user);
} catch (Exception e) {
Logger.error(this, "Error Fetching timeline", e);
return null;
}
} else {
Logger.info(this, "ViewTool not inited");
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.