use of twitter4j.conf.ConfigurationBuilder in project Talon-for-Twitter by klinker24.
the class Utils method getTwitter.
public static Twitter getTwitter(Context context) {
AppSettings settings = AppSettings.getInstance(context);
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY).setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET).setOAuthAccessToken(settings.authenticationToken).setOAuthAccessTokenSecret(settings.authenticationTokenSecret);
cb.setTweetModeExtended(true);
TwitterFactory tf = new TwitterFactory(cb.build());
return tf.getInstance();
}
use of twitter4j.conf.ConfigurationBuilder in project Talon-for-Twitter by klinker24.
the class Utils method getSecondTwitter.
public static Twitter getSecondTwitter(Context context) {
AppSettings settings = AppSettings.getInstance(context);
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY).setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET).setOAuthAccessToken(settings.secondAuthToken).setOAuthAccessTokenSecret(settings.secondAuthTokenSecret);
TwitterFactory tf = new TwitterFactory(cb.build());
return tf.getInstance();
}
use of twitter4j.conf.ConfigurationBuilder in project Talon-for-Twitter by klinker24.
the class Utils method getStreamingTwitter.
public static TwitterStream getStreamingTwitter(Context context, AppSettings settings) {
settings = AppSettings.getInstance(context);
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY).setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET).setOAuthAccessToken(settings.authenticationToken).setOAuthAccessTokenSecret(settings.authenticationTokenSecret);
TwitterStreamFactory tf = new TwitterStreamFactory(cb.build());
return tf.getInstance();
}
use of twitter4j.conf.ConfigurationBuilder in project camel by apache.
the class TwitterConfiguration method getConfiguration.
/**
* Builds a Twitter4J Configuration using the OAuth params.
*
* @return Configuration
*/
public Configuration getConfiguration() {
checkComplete();
ConfigurationBuilder confBuilder = new ConfigurationBuilder();
confBuilder.setOAuthConsumerKey(consumerKey);
confBuilder.setOAuthConsumerSecret(consumerSecret);
confBuilder.setOAuthAccessToken(accessToken);
confBuilder.setOAuthAccessTokenSecret(accessTokenSecret);
if (getHttpProxyHost() != null) {
confBuilder.setHttpProxyHost(getHttpProxyHost());
}
if (getHttpProxyUser() != null) {
confBuilder.setHttpProxyHost(getHttpProxyUser());
}
if (getHttpProxyPassword() != null) {
confBuilder.setHttpProxyHost(getHttpProxyPassword());
}
if (httpProxyPort != null) {
confBuilder.setHttpProxyPort(httpProxyPort);
}
return confBuilder.build();
}
use of twitter4j.conf.ConfigurationBuilder in project twitter4j by yusuke.
the class ApplicationOnlyAuthTest method testSettingAccessTokenFromPropertyFile.
public void testSettingAccessTokenFromPropertyFile() throws Exception {
String filename = "./twitter4j.properties";
try {
// setup
builder.setOAuthConsumerKey(browserConsumerKey).setOAuthConsumerSecret(browserConsumerSecret);
OAuth2Token token = new TwitterFactory(builder.build()).getInstance().getOAuth2Token();
writeFile(filename, "enableApplicationOnlyAuth=true", "http.useSSL=true", "oauth.consumerKey=" + browserConsumerKey, "oauth.consumerSecret=" + browserConsumerSecret, "oauth2.tokenType=" + token.getTokenType(), "oauth2.accessToken=" + token.getAccessToken());
Twitter twitter = new TwitterFactory(new ConfigurationBuilder().build()).getInstance();
// exercise & verify
Map<String, RateLimitStatus> rateLimitStatus = twitter.getRateLimitStatus("search");
RateLimitStatus searchTweetsRateLimit = rateLimitStatus.get("/search/tweets");
assertNotNull(searchTweetsRateLimit);
assertEquals(searchTweetsRateLimit.getLimit(), 450);
} finally {
deleteFile(filename);
}
}
Aggregations