diff --git a/libs/twitter4j-core-3.0.3.jar b/libs/twitter4j-core-3.0.6-SNAPSHOT.jar similarity index 56% rename from libs/twitter4j-core-3.0.3.jar rename to libs/twitter4j-core-3.0.6-SNAPSHOT.jar index b9394f4..c5d5f1e 100644 Binary files a/libs/twitter4j-core-3.0.3.jar and b/libs/twitter4j-core-3.0.6-SNAPSHOT.jar differ diff --git a/res/values/strings.xml b/res/values/strings.xml index edf978f..da00ab6 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -13,7 +13,7 @@ Organizations University Recent Alerts: - UNCC Game Day + UNCCGameDay unccharlotte Gameday.sqlite GamedayPreferences diff --git a/src/com/uncc/gameday/twitter/TwitterClient.java b/src/com/uncc/gameday/twitter/TwitterClient.java new file mode 100644 index 0000000..1404737 --- /dev/null +++ b/src/com/uncc/gameday/twitter/TwitterClient.java @@ -0,0 +1,51 @@ +package com.uncc.gameday.twitter; + +import java.util.ArrayList; +import java.util.List; + +import twitter4j.Paging; +import twitter4j.Status; +import twitter4j.Twitter; +import twitter4j.TwitterException; +import twitter4j.TwitterFactory; +import twitter4j.conf.Configuration; +import twitter4j.conf.ConfigurationBuilder; + +public class TwitterClient { + + static final String CONSUMER_KEY = "vfRa3Tr5QYaU8Jr2pKHtiA"; + static final String CONSUMER_SECRET = "gGRdIrhPdX2Vrg296xOvTqE4sgOISMphRmPdrGirbU"; + + Configuration c; + Twitter t; + + public TwitterClient() throws TwitterException { + ConfigurationBuilder cb = new ConfigurationBuilder(); + cb.setApplicationOnlyAuthEnabled(true).setUseSSL(true); + + t = new TwitterFactory(cb.build()).getInstance(); + t.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); + t.getOAuth2Token(); + } + + public List fetchTweets(String handle) { + try { + return t.getUserTimeline(handle); + } catch (TwitterException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return new ArrayList(); + } + } + + public List fetchTweets(String handle, int count) { + try { + return t.getUserTimeline(handle, new Paging(1, count)); + } catch (TwitterException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return new ArrayList(); + } + } + +}