-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter.pde
76 lines (60 loc) · 2.43 KB
/
twitter.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
String[] searchKeyword = {"#rookie13", "#AUTrookie"};
String tweetText = "this is a test tweet more to test with this particular method of writing a long ass tweet hahah it will be interesting to see how this pans out";
String userName;
/// This is where you enter your Oauth info
static String OAuthConsumerKey = "6S3yUwXt39a2tObbuhKgew";
static String OAuthConsumerSecret = "K3qyM4jGa1h5CHC0NsntHae57CdaozkJY6ybu6BOf4";
// This is where you enter your Access Token info
static String AccessToken = "453432604-EGc0xwvZCKwCSecwk51uFPTCjfL6nF9eOHB88mld";
static String AccessTokenSecret = "xlD67VS7WP9LV54P4gHf0AJ3ITS7fSJ4ogKlDg76XNanw";
// Sets the instance of a twitter stream
TwitterStream tstream = new TwitterStreamFactory().getInstance();
int logoCount = 0;
int insert = 5;
void connectTwitter() {
tstream.setOAuthConsumer(OAuthConsumerKey, OAuthConsumerSecret);
AccessToken accessToken = loadAccessToken();
tstream.setOAuthAccessToken(accessToken);
}
// Loading up the access token
private static AccessToken loadAccessToken() {
return new AccessToken(AccessToken, AccessTokenSecret);
}
StatusListener listener = new StatusListener() {
public void onStatus(Status status) {
//println("-"+x+" @" + status.getUser().getScreenName() + " - " + status.getText());
//displayTw(status);
// periodically add the rookie logo into the mix
// randomly between 4 and 8 tweets.. add the rookie logo
//int insert = (int)random(4,8);
if(logoCount == insert)
{
tweetText = "<";
userName = "SYSTEM";
logoCount = 0;
}
else
{
tweetText = status.getText();
userName = status.getUser().getScreenName();
logoCount++;
}
logoCount = logoCount % 6;
queueTweet(tweetText, userName);
}
public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
//System.out.println("Got a status deletion notice id:" + statusDeletionNotice.getStatusId());
}
public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
// System.out.println("Got track limitation notice:" + numberOfLimitedStatuses);
}
public void onScrubGeo(long userId, long upToStatusId) {
//System.out.println("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId);
}
public void onStallWarning(StallWarning warning) {
//System.out.println("Got stall warning:" + warning);
}
public void onException(Exception ex) {
ex.printStackTrace();
}
};