mirror of
https://github.com/bspeice/UNCCGameDay
synced 2024-12-04 05:48:10 -05:00
Twitter is now working.
This commit is contained in:
parent
9085b79d4a
commit
e5ee12d32e
Binary file not shown.
@ -13,7 +13,7 @@
|
||||
<string name="alerts_check_organizations">Organizations</string>
|
||||
<string name="alerts_check_university">University</string>
|
||||
<string name="home_label_recent_alerts">Recent Alerts:</string>
|
||||
<string name="gameday_handle">UNCC Game Day</string>
|
||||
<string name="gameday_handle">UNCCGameDay</string>
|
||||
<string name="university_handle">unccharlotte</string>
|
||||
<string name="db_path">Gameday.sqlite</string>
|
||||
<string name="preferences_file">GamedayPreferences</string>
|
||||
|
51
src/com/uncc/gameday/twitter/TwitterClient.java
Normal file
51
src/com/uncc/gameday/twitter/TwitterClient.java
Normal file
@ -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<Status> fetchTweets(String handle) {
|
||||
try {
|
||||
return t.getUserTimeline(handle);
|
||||
} catch (TwitterException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
return new ArrayList<Status>();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Status> 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<Status>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user