List of usage examples for twitter4j TwitterFactory TwitterFactory
public TwitterFactory(String configTreePath)
From source file:com.fuzuapp.model.resultados.TwitterAdapter.java
private void inicializar() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("56dJMai5O3H1MUjUl607LPgOh") .setOAuthConsumerSecret("wLsRXEDxDWAgOW217XbSiSK1J2WNG2gqxVDuLIqreI5VYfKEyD") .setOAuthAccessToken("64546879-myofEJ5cfPHwaRIud8mSBq2BmM68gHo9gGNgvj8Qb") .setOAuthAccessTokenSecret("dzJYWMs4QJUAwOCTisg5eSVLT5xhTp61ecuZ6fNpnARAI"); TwitterFactory tf = new TwitterFactory(cb.build()); twitter = tf.getInstance();/*ww w .j a va 2 s . c o m*/ }
From source file:com.github.altyjp.webChangeDetector.TweetStrings.java
/** * ?/* w w w. ja v a 2s .com*/ * * @param str_tweet * @throws TwitterException */ public void tweetString(String str_tweet) throws TwitterException { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(ConsumerKey).setOAuthConsumerSecret(ConsumerSecret) .setOAuthAccessToken(AccessToken).setOAuthAccessTokenSecret(AccessTokenSecret); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); //User user = twitter.verifyCredentials(); //? //System.out.println("???" + user.getName()); //System.out.println("?????" + user.getScreenName()); //System.err.println("???" + user.getFriendsCount()); //System.out.println("????" + user.getFollowersCount()); //?????? Status status = twitter.updateStatus(str_tweet); }
From source file:com.github.gorbin.asne.twitter.TwitterSocialNetwork.java
License:Open Source License
private void initTwitterClient() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setOAuthConsumerKey(fConsumerKey); builder.setOAuthConsumerSecret(fConsumerSecret); String accessToken = mSharedPreferences.getString(SAVE_STATE_KEY_OAUTH_TOKEN, null); String accessTokenSecret = mSharedPreferences.getString(SAVE_STATE_KEY_OAUTH_SECRET, null); TwitterFactory factory = new TwitterFactory(builder.build()); if (TextUtils.isEmpty(accessToken) && TextUtils.isEmpty(accessTokenSecret)) { mTwitter = factory.getInstance(); } else {// w w w . j a v a2 s . co m mTwitter = factory.getInstance(new AccessToken(accessToken, accessTokenSecret)); } }
From source file:com.github.hiro2k.logback.twitter.TwitterAppender.java
License:Apache License
@Override public void start() { boolean requiredPropsSet = true; if (getAccessToken() == null) { addStatus(new ErrorStatus("Access token not set", this)); requiredPropsSet = false;/*from w w w . j av a 2 s. com*/ } if (getAccessSecret() == null) { addStatus(new ErrorStatus("Access secret not set", this)); requiredPropsSet = false; } if (getConsumerKey() == null) { addStatus(new ErrorStatus("Consumer key not set", this)); requiredPropsSet = false; } if (getConsumerSecret() == null) { addStatus(new ErrorStatus("Consumer Secret not set", this)); requiredPropsSet = false; } if (!requiredPropsSet && twitter == null) { addWarn("Appender not started because the required properties weren't all set."); return; } if (layout == null) { layout = makeDefaultPatternLayout(); } if (twitter == null) { ConfigurationBuilder configBuilder = new ConfigurationBuilder(); configBuilder.setOAuthConsumerKey(consumerKey).setOAuthConsumerSecret(consumerSecret) .setOAuthAccessToken(accessToken).setOAuthAccessTokenSecret(accessSecret); TwitterFactory tf = new TwitterFactory(configBuilder.build()); this.twitter = tf.getInstance(); } super.start(); }
From source file:com.ibuildapp.romanblack.CameraPlugin.SharingActivity.java
License:Open Source License
/** * Reinitializes twitter credentials.//from w w w . j av a 2s. c o m * @return the twitter instance */ private Twitter reInitTwitter() { com.appbuilder.sdk.android.authorization.entities.User twitterUser = Authorization .getAuthorizedUser(Authorization.AUTHORIZATION_TYPE_TWITTER); ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setDebugEnabled(true).setOAuthAccessToken(twitterUser.getAccessToken()) .setOAuthAccessTokenSecret(twitterUser.getAccessTokenSecret()) .setOAuthConsumerSecret(Statics.TWITTER_CONSUMER_SECRET) .setOAuthConsumerKey(Statics.TWITTER_CONSUMER_KEY); Configuration configuration = builder.build(); return new TwitterFactory(configuration).getInstance(); }
From source file:com.ijuru.tweetgrab.Context.java
License:Open Source License
/** * Starts the application//ww w . ja v a2 s. com * @throws Exception */ public static void startApplication() throws Exception { // Look for environment variable or system property String optionsJSON = System.getenv(ENVVAR_NAME); if (optionsJSON == null) { optionsJSON = System.getProperty(JVMPROP_NAME); if (optionsJSON == null) { throw new Exception("Could not find environment variable (" + ENVVAR_NAME + ") or JVM property (" + JVMPROP_NAME + ")"); } } ObjectMapper mapper = new ObjectMapper(); options = mapper.readValue(optionsJSON, Options.class); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(false).setOAuthConsumerKey(options.getCredentials().get("consumerKey")) .setOAuthConsumerSecret(options.getCredentials().get("consumerSecret")) .setOAuthAccessToken(options.getCredentials().get("accessToken")) .setOAuthAccessTokenSecret(options.getCredentials().get("accessTokenSecret")); twitterFactory = new TwitterFactory(cb.build()); }
From source file:com.illusionaryone.TwitterAPI.java
License:Open Source License
public Boolean authenticate() { com.gmt2001.Console.debug.println("Attempting to Authenticate"); try {// w w w. j ava2 s .co m ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(consumerKey); configurationBuilder.setOAuthConsumerSecret(consumerSecret); configurationBuilder.setOAuthAccessToken(oauthAccessToken); configurationBuilder.setOAuthAccessTokenSecret(oauthAccessSecret); TwitterFactory twitterFactory = new TwitterFactory(configurationBuilder.build()); twitter = twitterFactory.getInstance(); accessToken = twitter.getOAuthAccessToken(); com.gmt2001.Console.out.println("Authenticated with Twitter API"); return true; } catch (TwitterException ex) { com.gmt2001.Console.err.println("Twitter Auth Failed: " + ex.getMessage()); accessToken = null; return false; } }
From source file:com.infine.android.devoxx.service.TwitterService.java
License:Apache License
@Override public void onCreate() { super.onCreate(); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("************").setOAuthConsumerSecret("****************") .setOAuthAccessToken("***************").setOAuthAccessTokenSecret("**************"); TwitterFactory tf = new TwitterFactory(cb.build()); mTwitter = tf.getInstance();/*from ww w . ja v a2 s .c om*/ mResolver = getContentResolver(); }
From source file:com.irontec.mintzatu.EzarpenakDetailActivity.java
private void askOAuth() { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setOAuthConsumerKey(TwitterHelper.CONSUMER_KEY); configurationBuilder.setOAuthConsumerSecret(TwitterHelper.CONSUMER_SECRET); Configuration configuration = configurationBuilder.build(); twitter = new TwitterFactory(configuration).getInstance(); try {//from w w w . j a v a2 s .co m requestToken = twitter.getOAuthRequestToken(TwitterHelper.CALLBACK_URL); Intent i = new Intent(this, WebviewActivity.class); i.putExtra("URL", requestToken.getAuthenticationURL()); startActivityForResult(i, TWITTER_AUTH); } catch (TwitterException e) { e.printStackTrace(); } }
From source file:com.isdp.twitterposter.TwitterManager.java
License:Open Source License
public void tweet(String message) { TwitterFactory tf = new TwitterFactory(configuration); Twitter twitter = tf.getInstance();/*from ww w . j a va2 s .c om*/ try { Status status = twitter.updateStatus(message); System.out.println("Tweet status: Successfully updated the status to [" + status.getText() + "]."); } catch (Exception e) { e.printStackTrace(); } }