Permalink
Browse files

tuit service fix

  • Loading branch information...
1 parent c780224 commit f96ca72b3ae71c180c846a2533d76b11da67098b Luis Farzati committed Apr 28, 2011
Showing with 15 additions and 5 deletions.
  1. +15 −5 modules/tuitconnect/app/tuitconnect/TuitService.java
@@ -15,20 +15,25 @@
private final static String CONSUMER_KEY = Play.configuration.getProperty("tuit.consumerKey");
private final static String CONSUMER_SECRET = Play.configuration.getProperty("tuit.consumerSecret");
- private static Configuration getConfiguration(TwitterAccount account)
- {
+ private static Configuration getConfiguration(String token, String tokenSecret) {
ConfigurationBuilder conf = new ConfigurationBuilder();
conf.setOAuthConsumerKey(CONSUMER_KEY)
.setOAuthConsumerSecret(CONSUMER_SECRET);
- if(account != null) {
- conf.setOAuthAccessToken(account.token)
- .setOAuthAccessTokenSecret(account.tokenSecret);
+ if(token != null && tokenSecret != null) {
+ conf.setOAuthAccessToken(token)
+ .setOAuthAccessTokenSecret(tokenSecret);
}
return conf.build();
}
+ private static Configuration getConfiguration(TwitterAccount account) {
+ String token = account != null ? account.token : null;
+ String tokenSecret = account != null ? account.tokenSecret : null;
+ return getConfiguration(token, tokenSecret);
+ }
+
public static Twitter twitterFactory(TwitterAccount account) {
TwitterFactory factory = new TwitterFactory(getConfiguration(account));
return factory.getInstance();
@@ -37,6 +42,11 @@ public static Twitter twitterFactory(TwitterAccount account) {
public static Twitter twitterFactory() {
return twitterFactory(null);
}
+
+ public static TwitterStream streamFactory(String token, String tokenSecret) {
+ TwitterStreamFactory factory = new TwitterStreamFactory(getConfiguration(token, tokenSecret));
+ return factory.getInstance();
+ }
public static TwitterStream streamFactory(TwitterAccount account) {
TwitterStreamFactory factory = new TwitterStreamFactory(getConfiguration(account));

0 comments on commit f96ca72

Please sign in to comment.