Skip to content

Instantly share code, notes, and snippets.

@cfalzone
Last active December 16, 2015 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfalzone/5356502 to your computer and use it in GitHub Desktop.
Save cfalzone/5356502 to your computer and use it in GitHub Desktop.
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