List of usage examples for twitter4j.conf ConfigurationBuilder setOAuthAccessTokenSecret
public ConfigurationBuilder setOAuthAccessTokenSecret(String oAuthAccessTokenSecret)
From source file:OAuth.MyOwnTwitterFactory.java
License:Open Source License
public Twitter createOneTwitterInstance() { Twitter twitter;// w w w . ja va 2s .co 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;/*w w w .j a v a2 s . co 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;//w w w . ja v a 2 s . co 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 w ww . java 2 s. c om*/ */ 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 ww. j av a 2 s . c om logConfig(); }
From source file:org.botlibre.sense.twitter.Twitter.java
License:Open Source License
public void connect() throws TwitterException { initProperties();//from w ww . ja v a 2 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 {// w w w . ja v a 2 s .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(); }
From source file:org.jraf.irondad.handler.twitter.follow.TwitterFollowHandler.java
License:Open Source License
private static Twitter getTwitter(HandlerContext handlerContext) { Twitter res = (Twitter) handlerContext.get("twitter"); if (res == null) { TwitterFollowHandlerConfig twitterFollowHandlerConfig = (TwitterFollowHandlerConfig) handlerContext .getHandlerConfig();/* ww w .j a va2 s. co m*/ ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setDebugEnabled(true) .setOAuthConsumerKey(twitterFollowHandlerConfig.getOauthConsumerKey()); configurationBuilder.setOAuthConsumerSecret(twitterFollowHandlerConfig.getOauthConsumerSecret()); configurationBuilder.setOAuthAccessToken(twitterFollowHandlerConfig.getOauthAccessToken()); configurationBuilder.setOAuthAccessTokenSecret(twitterFollowHandlerConfig.getOauthAccessTokenSecret()); TwitterFactory twitterFactory = new TwitterFactory(configurationBuilder.build()); res = twitterFactory.getInstance(); handlerContext.put("twitter", res); } return res; }
From source file:org.jraf.irondad.handler.twitter.links.TwitterLinksHandler.java
License:Open Source License
private static Twitter getTwitter(HandlerContext handlerContext) { Twitter res = (Twitter) handlerContext.get("twitter"); if (res == null) { TwitterLinksHandlerConfig twitterLinksHandlerConfig = (TwitterLinksHandlerConfig) handlerContext .getHandlerConfig();/* w w w .j a v a2 s . c o m*/ ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setDebugEnabled(true) .setOAuthConsumerKey(twitterLinksHandlerConfig.getOauthConsumerKey()); configurationBuilder.setOAuthConsumerSecret(twitterLinksHandlerConfig.getOauthConsumerSecret()); configurationBuilder.setOAuthAccessToken(twitterLinksHandlerConfig.getOauthAccessToken()); configurationBuilder.setOAuthAccessTokenSecret(twitterLinksHandlerConfig.getOauthAccessTokenSecret()); TwitterFactory twitterFactory = new TwitterFactory(configurationBuilder.build()); res = twitterFactory.getInstance(); handlerContext.put("twitter", res); } return res; }