List of usage examples for twitter4j.conf ConfigurationBuilder setOAuthConsumerSecret
public ConfigurationBuilder setOAuthConsumerSecret(String oAuthConsumerSecret)
From source file:com.learnncode.demotwitterimagepost.LoginActivity.java
License:Apache License
private void askOAuth() { final ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(twitterConsumerKey); configurationBuilder.setOAuthConsumerSecret(twitterConsumerSecret); final Configuration configuration = configurationBuilder.build(); twitter = new TwitterFactory(configuration).getInstance(); new Thread(new Runnable() { @Override/*from ww w . jav a2 s . c om*/ public void run() { try { requestToken = twitter.getOAuthRequestToken(AppConstantTwitter.TWITTER_CALLBACK_URL); } catch (final Exception e) { final String errorString = e.toString(); LoginActivity.this.runOnUiThread(new Runnable() { @Override public void run() { if (busyDialog != null) { busyDialog.dismis(); } Toast.makeText(LoginActivity.this, errorString.toString(), Toast.LENGTH_SHORT).show(); finish(); } }); return; } LoginActivity.this.runOnUiThread(new Runnable() { @Override public void run() { twitterLoginWebView.loadUrl(requestToken.getAuthenticationURL()); } }); } }).start(); }
From source file:com.learnncode.twitter.Utilities.TwitterHelper.java
License:Apache License
public static Twitter getTwitterInstance(Context _Context) { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(_Context.getResources().getString(R.string.twitter_consumer_key)); configurationBuilder .setOAuthConsumerSecret(_Context.getResources().getString(R.string.twitter_consumer_secret)); configurationBuilder.setOAuthAccessToken(AppSettings.getTwitterAccessToken((_Context))); configurationBuilder.setOAuthAccessTokenSecret(AppSettings.getTwitterAccessTokenSecret(_Context)); Configuration configuration = configurationBuilder.build(); return new TwitterFactory(configuration).getInstance(); }
From source file:com.learnncode.twitter.Utilities.TwitterHelper.java
License:Apache License
public static Twitter getTwitterInstanceWithoutAuthentication(Context _Context) { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(_Context.getResources().getString(R.string.twitter_consumer_key)); configurationBuilder .setOAuthConsumerSecret(_Context.getResources().getString(R.string.twitter_consumer_secret)); configurationBuilder.setOAuthAccessToken(_Context.getResources().getString(R.string.twitter_access_token)); configurationBuilder/*from ww w. ja v a2 s . c om*/ .setOAuthAccessTokenSecret(_Context.getResources().getString(R.string.twitter_access_token_secret)); Configuration configuration = configurationBuilder.build(); return new TwitterFactory(configuration).getInstance(); }
From source file:com.left8.evs.utilities.dsretriever.TweetsRetriever.java
License:Open Source License
/** * Method to get authorization from Twitter API. * @return A ConfigurationBuilder object. *//*from w w w . j ava 2 s . c o m*/ public ConfigurationBuilder getAuthorization() { ConfigurationBuilder cb = new ConfigurationBuilder(); Config conf; try { conf = new Config(); } catch (IOException e) { Logger.getLogger(TweetsRetriever.class.getName()).log(Level.SEVERE, null, e); return null; } cb.setOAuthConsumerKey(conf.getConsumerKey()); cb.setOAuthConsumerSecret(conf.getConsumerSecret()); cb.setOAuthAccessToken(conf.getAccessToken()); cb.setOAuthAccessTokenSecret(conf.getAccessTokenSecret()); return cb; }
From source file:com.marpies.ane.twitter.data.TwitterAPI.java
License:Apache License
/** * * * Public API/* w w w . j a va 2 s . c om*/ * * */ public static void init(String consumerKey, String consumerSecret, String urlScheme) { if (mIsInitialized) return; mURLScheme = urlScheme; ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setOAuthConsumerKey(consumerKey); builder.setOAuthConsumerSecret(consumerSecret); mConfiguration = builder.build(); mIsInitialized = true; }
From source file:com.mycompany.mech2015task.App.java
public static void main(String[] args) throws Exception { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setOAuthConsumerKey(CONSUMER_KEY); builder.setOAuthConsumerSecret(CONSUMER_SECRET); builder.setOAuthAccessToken(ACCESS_TOKEN); builder.setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET); // ??Twitter4J??API???betastream.twitter.com??????? builder.setUserStreamBaseURL("https://userstream.twitter.com/2/"); // Configuration? Configuration configuration = builder.build(); /* Configuration configuration = new ConfigurationBuilder().setOAuthConsumerKey(CONSUMER_KEY) .setOAuthConsumerSecret(CONSUMER_SECRET) .setOAuthAccessToken(ACCESS_TOKEN) .setOAuthAccessTokenSecret(ACCESS_TOKEN_SECRET) .build();/*from w ww . j a v a 2s .c o m*/ */ TwitterStream twStream = new TwitterStreamFactory(configuration).getInstance(); //TwitterStream twStream = new TwitterStreamFactory().getInstance(); twStream.addListener(new MyStatusListener()); twStream.user(); //twStream.sample(); }
From source file:com.mysportsshare.mysportscast.utils.HelperMethods.java
License:Apache License
public static void postToTwitter(Context context, final Activity callingActivity, final String message, final TwitterCallback postResponse) { SharedPreferences mSharedPref = context.getSharedPreferences("Android_Twitter_Preferences", Context.MODE_PRIVATE); if (mSharedPref.getString(Constants.KEY_TWITTER_ACCESS_TOKEN, null) == null) { postResponse.onFinsihed(false);/*from ww w. j a v a2 s. co m*/ return; } ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(HomeActivity.CONSUMER_KEY); configurationBuilder.setOAuthConsumerSecret(HomeActivity.CONSUMER_SECRET); configurationBuilder.setOAuthAccessToken(HomeActivity.getAccessToken((context))); configurationBuilder.setOAuthAccessTokenSecret(HomeActivity.getAccessTokenSecret(context)); Configuration configuration = configurationBuilder.build(); final Twitter twitter = new TwitterFactory(configuration).getInstance(); new Thread(new Runnable() { private double x; @Override public void run() { boolean success = true; try { x = Math.random(); twitter.updateStatus(message); } catch (TwitterException e) { e.printStackTrace(); success = false; } final boolean finalSuccess = success; callingActivity.runOnUiThread(new Runnable() { @Override public void run() { postResponse.onFinsihed(finalSuccess); } }); } }).start(); }
From source file:com.mysportsshare.mysportscast.utils.HelperMethods.java
License:Apache License
public static void postToTwitterWithImage(Context context, final Activity callingActivity, final String imageUrl, final String message, final TwitterCallback postResponse) { SharedPreferences mSharedPref = context.getSharedPreferences("Android_Twitter_Preferences", Context.MODE_PRIVATE); if (mSharedPref.getString(Constants.KEY_TWITTER_ACCESS_TOKEN, null) == null) { postResponse.onFinsihed(false);//ww w.ja v a 2 s . com return; } ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(HomeActivity.CONSUMER_KEY); configurationBuilder.setOAuthConsumerSecret(HomeActivity.CONSUMER_SECRET); configurationBuilder.setOAuthAccessToken(HomeActivity.getAccessToken((context))); configurationBuilder.setOAuthAccessTokenSecret(HomeActivity.getAccessTokenSecret(context)); Configuration configuration = configurationBuilder.build(); final Twitter twitter = new TwitterFactory(configuration).getInstance(); final File file = new File(imageUrl); new Thread(new Runnable() { @Override public void run() { boolean success = true; try { if (file.exists()) { StatusUpdate status = new StatusUpdate(message); status.setMedia(file); twitter.updateStatus(status); } else { Log.d(TAG, "----- Invalid File ----------"); success = false; } } catch (Exception e) { e.printStackTrace(); success = false; } final boolean finalSuccess = success; callingActivity.runOnUiThread(new Runnable() { @Override public void run() { postResponse.onFinsihed(finalSuccess); } }); } }).start(); }
From source file:com.narvis.frontend.twitter.AccessTwitter.java
License:Open Source License
private Pair<TwitterStream, Twitter> loadAccessTwitter(String token, String tokenSecret, String consumerKey, String consumerSecret) {/* w w w .ja v a 2 s. co m*/ ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true); cb.setOAuthConsumerKey(consumerKey); cb.setOAuthConsumerSecret(consumerSecret); cb.setOAuthAccessToken(token); cb.setOAuthAccessTokenSecret(tokenSecret); Configuration authConf = cb.build(); return new Pair(new TwitterStreamFactory(authConf).getInstance(), new TwitterFactory(authConf).getInstance()); }
From source file:com.nookdevs.twook.activities.Settings.java
License:Open Source License
public ConfigurationBuilder getConfiguration() { ConfigurationBuilder confBuilder = new ConfigurationBuilder(); confBuilder.setOAuthConsumerKey(consumerKey); confBuilder.setOAuthConsumerSecret(consumerSecret); return confBuilder; }