-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTwitterAccount.java
More file actions
98 lines (88 loc) · 2.03 KB
/
TwitterAccount.java
File metadata and controls
98 lines (88 loc) · 2.03 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import twitter4j.*;
import twitter4j.conf.ConfigurationBuilder;
/**
* @author Aashish Jain
* @version September 20, 2015
*
* A Twitter account holds authentication keys from twitter and is also an
* instance of a twitter (twitter4j).
*/
public class TwitterAccount
{
//consumer key from twitter api
private String cKey;
//consumer secret from twitter api
private String cSecret;
//authentication token from twitter api
private String aToken;
//authentication token secret from twitter api
private String aTokenSecret;
//this accounts twitter instance
private Twitter twitter;
/**
* The constructor for this TwitterAccount.
* @param cK the cKey
* @param cS the cSecret
* @param aT the aToken
* @param aTS the aTokenSecret
*/
public TwitterAccount(String cK, String cS, String aT, String aTS)
{
setcKey(cK);
setcSecret(cS);
setaToken(aT);
setaTokenSecret(aTS);
createTwitter();
}
/**
* Sets the twitter instance variable from the authentication keys already
* gathered.
*/
public void createTwitter()
{
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(cKey)
.setOAuthConsumerSecret(cSecret)
.setOAuthAccessToken(aToken)
.setOAuthAccessTokenSecret(aTokenSecret);
TwitterFactory tf = new TwitterFactory(cb.build());
twitter = tf.getInstance();
}
/**
* Sets the cKey to what is specified.
* @param cK sets the cKey to this string.
*/
public void setcKey(String cK)
{
cKey = cK;
}
/**
* Sets the cSecret to what is specified;
* @param cS sets the cSecret to this string.
*/
public void setcSecret(String cS)
{
cSecret = cS;
}
/**
* sets the aToken to what is specified.
* @param aT sets the aToken to this string.
*/
public void setaToken(String aT)
{
aToken = aT;
}
/**
* Sets the aTokenSecret to what is specified.
* @param aTS sets the aTokenSecret to this string.
*/
public void setaTokenSecret(String aTS)
{
aTokenSecret = aTS;
}
public Twitter getTwitter()
{
return twitter;
}
}