List of usage examples for twitter4j.conf ConfigurationBuilder setOAuthAccessToken
public ConfigurationBuilder setOAuthAccessToken(String oAuthAccessToken)
From source file:Jums.AllAPI.java
public static Configuration TwitterConnect() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true);/*from ww w .ja v a2s . co m*/ cb.setOAuthConsumerKey(CONSUMERKEY); cb.setOAuthConsumerSecret(CONSUMERSECRET); cb.setOAuthAccessToken(TOKEN); cb.setOAuthAccessTokenSecret(TOKENSECRET); return cb.build(); }
From source file:Jums.SearchTweet.java
public void main(PrintWriter out) { try {/* w ww . j a v a2 s.co m*/ ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true); cb.setOAuthConsumerKey(CONSUMERKEY); cb.setOAuthConsumerSecret(CONSUMERSECRET); cb.setOAuthAccessToken(TOKEN); cb.setOAuthAccessTokenSecret(TOKENSECRET); Twitter tw = new TwitterFactory(cb.build()).getInstance(); User user = tw.verifyCredentials(); List<Status> statuses = tw.getHomeTimeline(); for (Status s : statuses) { } } catch (Exception e) { e.printStackTrace(); } }
From source file:OAuth.MyOwnTwitterFactory.java
License:Open Source License
public Twitter createOneTwitterInstance() { Twitter twitter;/* w ww. j a v a 2 s . c o m*/ ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setOAuthConsumerKey(APIkeys.getTwitterAPIKey()); builder.setOAuthConsumerSecret(APIkeys.getTwitterAPISecret()); builder.setOAuthAccessToken("31805620-QQy8TFFDKRxWyOUVnY08UcxT5bzrFhRWUa0A3lEW3"); builder.setOAuthAccessTokenSecret("iJuCkdgrfIpGn5odyF2evMSvAsovreeEV6cZU5ihVVI7j"); Configuration configuration = builder.build(); TwitterFactory factory = new TwitterFactory(configuration); twitter = factory.getInstance(); return twitter; }
From source file:OAuth.MyOwnTwitterFactory.java
License:Open Source License
public TwitterStream createOneTwitterStreamInstance(AccessToken accessToken) { TwitterStream twitterStream;//from w w w . j av a 2s . c o m ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setOAuthConsumerKey(APIkeys.getTwitterAPIKey()); builder.setOAuthConsumerSecret(APIkeys.getTwitterAPISecret()); System.out.println("AT: " + accessToken.getToken()); System.out.println("ATS: " + accessToken.getTokenSecret()); builder.setOAuthAccessToken(accessToken.getToken()); builder.setOAuthAccessTokenSecret(accessToken.getTokenSecret()); builder.setJSONStoreEnabled(true); // builder.setOAuthAccessToken("31805620-QQy8TFFDKRxWyOUVnY08UcxT5bzrFhRWUa0A3lEW3"); // builder.setOAuthAccessTokenSecret("iJuCkdgrfIpGn5odyF2evMSvAsovreeEV6cZU5ihVVI7j"); Configuration configuration = builder.build(); TwitterStreamFactory factory = new TwitterStreamFactory(configuration); twitterStream = factory.getInstance(); return twitterStream; }
From source file:OAuth.MyOwnTwitterFactory.java
License:Open Source License
public TwitterStream createOneTwitterStreamInstanceFromApp(String APIKey, String APIKeySecret, String accessToken, String accessTokenSecret) { TwitterStream twitterStream;/*from ww w .j a va2 s. c o m*/ ConfigurationBuilder builder = new ConfigurationBuilder(); if (!Admin.isTest()) { builder.setOAuthConsumerKey(APIKey); builder.setOAuthConsumerSecret(APIKeySecret); builder.setOAuthAccessToken(accessToken); builder.setOAuthAccessTokenSecret(accessTokenSecret); builder.setJSONStoreEnabled(true); } else { builder.setOAuthConsumerKey("KNjw1QTK1hJKx8LpK6X6rg"); builder.setOAuthConsumerSecret("ikX9blowuh3FqFAkIg5LQi5voLOV413EWzPsDl77uU"); builder.setOAuthAccessToken("31805620-QQy8TFFDKRxWyOUVnY08UcxT5bzrFhRWUa0A3lEW3"); builder.setOAuthAccessTokenSecret("iJuCkdgrfIpGn5odyF2evMSvAsovreeEV6cZU5ihVVI7j"); builder.setJSONStoreEnabled(true); } Configuration configuration = builder.build(); TwitterStreamFactory factory = new TwitterStreamFactory(configuration); twitterStream = factory.getInstance(); return twitterStream; }
From source file:org.apache.camel.component.twitter.TwitterConfiguration.java
License:Apache License
/** * Builds a Twitter4J Configuration using the OAuth params. * * @return Configuration/*from ww w. ja v a2 s . co m*/ */ public Configuration getConfiguration() { checkComplete(); ConfigurationBuilder confBuilder = new ConfigurationBuilder(); confBuilder.setOAuthConsumerKey(consumerKey); confBuilder.setOAuthConsumerSecret(consumerSecret); confBuilder.setOAuthAccessToken(accessToken); confBuilder.setOAuthAccessTokenSecret(accessTokenSecret); confBuilder.setUseSSL(useSSL); 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(); }
From source file:org.apache.solr.handler.dataimport.TwitterEntityProcessor.java
License:Apache License
public void init(Context context) { super.init(context); // get parameters String consumerKey = getStringFromContext("consumerKey", null); String consumerSecret = getStringFromContext("consumerSecret", null); String accessToken = getStringFromContext("accessToken", null); String accessTokenSecret = getStringFromContext("accessTokenSecret", null); // connect to twitter ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setOAuthConsumerKey(consumerKey); cb.setOAuthConsumerSecret(consumerSecret); cb.setOAuthAccessToken(accessToken); cb.setOAuthAccessTokenSecret(accessTokenSecret); twitter = new TwitterFactory(cb.build()).getInstance(); // initiate the search String criteria = getStringFromContext("criteria", null); since = context.replaceTokens("${dih.last_index_time}"); query = new Query(criteria); //query.setSince(since.substring(0, since.indexOf(" ")).trim()); query.setSince("2015-02-12"); index = 0;//from w w w .j a v a 2 s . com logConfig(); }
From source file:org.botlibre.sense.twitter.Twitter.java
License:Open Source License
public void connect() throws TwitterException { initProperties();/*from w w w . j av a2 s.com*/ ConfigurationBuilder config = new ConfigurationBuilder(); config.setOAuthConsumerKey(getOauthKey()); config.setOAuthConsumerSecret(getOauthSecret()); config.setOAuthAccessToken(getToken()); config.setOAuthAccessTokenSecret(getTokenSecret()); twitter4j.Twitter twitter = new TwitterFactory(config.build()).getInstance(); User user = twitter.verifyCredentials(); if (!this.userName.equals(user.getScreenName())) { this.userName = user.getScreenName(); saveProperties(null); } //AccessToken accessToken = new AccessToken(getToken(), getTokenSecret()); //twitter4j.Twitter twitter = new TwitterFactory().getInstance(accessToken); //twitter4j.Twitter twitter = new TwitterFactory().getInstance(getOauthKey(), getOauthSecret(), accessToken); //twitter4j.Twitter twitter = new TwitterFactory().getInstance(getUsername(), getPassword()); setConnection(twitter); }
From source file:org.fossasia.phimpme.share.twitter.HelperMethods.java
License:Apache License
public static void postToTwitterWithImage(Context context, final String imageUrl, final String message, final String token, final String secret, final TwitterCallback postResponse) { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(TWITTER_CONSUMER_KEY); configurationBuilder.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET); configurationBuilder.setOAuthAccessToken(token); configurationBuilder.setOAuthAccessTokenSecret(secret); Configuration configuration = configurationBuilder.build(); final Twitter twitter = new TwitterFactory(configuration).getInstance(); final File file = new File(imageUrl); boolean success = true; if (file.exists()) { try {//from ww w . j a v a 2s .c o m StatusUpdate status = new StatusUpdate(message); status.setMedia(file); twitter.updateStatus(status); } catch (TwitterException e) { e.printStackTrace(); success = false; } } else { Log.d(TAG, "----- Invalid File ----------"); success = false; } postResponse.onFinsihed(success); }
From source file:org.gatein.security.oauth.twitter.TwitterProcessorImpl.java
License:Open Source License
@Override public Twitter getAuthorizedTwitterInstance(TwitterAccessTokenContext accessTokenContext) { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setOAuthConsumerKey(clientID).setOAuthConsumerSecret(clientSecret); // Now add accessToken properties to builder builder.setOAuthAccessToken(accessTokenContext.getAccessToken()); builder.setOAuthAccessTokenSecret(accessTokenContext.getAccessTokenSecret()); // Return twitter instance with successfully established accessToken return new TwitterFactory(builder.build()).getInstance(); }