Last active
December 16, 2015 01:39
-
-
Save cfalzone/5356502 to your computer and use it in GitHub Desktop.
Just an example using Twiter4J in a Velocity ViewTool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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