List of usage examples for twitter4j TwitterFactory getInstance
public Twitter getInstance()
From source file:com.chantake.MituyaProject.Tool.Twitter.TwitterManager.java
License:Open Source License
/** * ?/*from w w w . ja v a 2 s . c o m*/ */ public void init() { plugin.Log("Twitter????"); TwitterFactory factory = new TwitterFactory(); //AccessToken at = new AccessToken(tokenKey, tokenSecret); // AccessToken?? this.twitter = factory.getInstance(); //this.twitter.setOAuthConsumer(consumerKey, consumerSecret); plugin.Log("Twitter????"); }
From source file:com.daiv.android.twitter.utils.Utils.java
License:Apache License
public static Twitter getTwitter(Context context, AppSettings settings) { if (settings == null) { settings = AppSettings.getInstance(context); }/*from ww w .j av a 2s . com*/ ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY) .setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET) .setOAuthAccessToken(settings.authenticationToken) .setOAuthAccessTokenSecret(settings.authenticationTokenSecret); TwitterFactory tf = new TwitterFactory(cb.build()); return tf.getInstance(); }
From source file:com.daiv.android.twitter.utils.Utils.java
License:Apache License
public static Twitter getTwitter(Context context) { AppSettings settings = AppSettings.getInstance(context); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY) .setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET) .setOAuthAccessToken(settings.authenticationToken) .setOAuthAccessTokenSecret(settings.authenticationTokenSecret); TwitterFactory tf = new TwitterFactory(cb.build()); return tf.getInstance(); }
From source file:com.daiv.android.twitter.utils.Utils.java
License:Apache License
public static Twitter getSecondTwitter(Context context) { AppSettings settings = AppSettings.getInstance(context); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY) .setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET) .setOAuthAccessToken(settings.secondAuthToken) .setOAuthAccessTokenSecret(settings.secondAuthTokenSecret); TwitterFactory tf = new TwitterFactory(cb.build()); return tf.getInstance(); }
From source file:com.dhamacher.sentimentanalysis4tweets.twitterapi.TweetOperator.java
License:Apache License
public TweetOperator(int mode) { try {/*from w w w. j av a 2s . co m*/ this.mode = mode; db = Operator.getInstance(); } catch (Exception ex) { ex.printStackTrace(); } if (mode == 3 || mode == 2) { TwitterFactory twitterFactory = new TwitterFactory(buildConfig()); twitter = twitterFactory.getInstance(); } }
From source file:com.dvd.codechallenge.Challengue.java
public static Tweets getTweets(String user) throws TwitterException { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("sMYxrCslzDDHGhFn5MSvPMWhw") .setOAuthConsumerSecret("ip8E4OoTGNQetDHz8oTereIsXAnO2cGlgs7Dd2S4lXti4weHAt") .setOAuthAccessToken("451175684-DBydPtZsitmr6EHPVansnVygQXRALCCKnKUqUa4W") .setOAuthAccessTokenSecret("prPHOfZj3IMFrW7ToFbKWJkRjWHM2qlpUdSecEZyuhLvd"); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); List<Status> statuses = twitter.getUserTimeline(user); // System.out.println("Tweets recuperados"); // statuses.forEach(x -> System.out.println(x.getUser().getName() // + "-> " + x.getUser().getScreenName() + ":::" // + x.getText())); Tweets ts = new Tweets(); statuses.forEach(x -> ts.addTweet(x.getText())); return ts;/*from w w w . j ava2 s .c o m*/ }
From source file:com.eclipsesource.iot.photosensor.example.Main.java
License:Open Source License
private static Twitter setupTwitter() throws TwitterException { if (TWITTER_CONFIGURED) { TwitterFactory factory = new TwitterFactory(); final Twitter twitter = factory.getInstance(); AccessToken accessToken = loadAccessToken(); authenticateTwitter(accessToken, twitter); currentStatus = getCurrentStatus(twitter); return twitter; }/*from w ww.ja v a 2 s. com*/ return null; }
From source file:com.example.leonid.twitterreader.Twitter.TwitterGetTweets.java
License:Apache License
@Override protected List<CreateTweet> doInBackground(String... params) { mTweetsInfo = new ArrayList<>(); List<String> texts = new ArrayList<>(); List<String> titles = new ArrayList<>(); List<String> images = new ArrayList<>(); List<String> date = new ArrayList<>(); if (!isCancelled()) { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(CONSUMER_KEY).setOAuthConsumerSecret(CONSUMER_SECRET) .setOAuthAccessToken(ACCESS_KEY).setOAuthAccessTokenSecret(ACCESS_SECRET); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); //query search result Query query = new Query(params[0]); //how much tweets need to be displayed(max 200) query.count(200);// w w w. j a v a2s .c om try { mResult = twitter.search(query); for (twitter4j.Status status : mResult.getTweets()) { if (!isCancelled()) { texts.add(status.getText()); titles.add(status.getUser().getName()); images.add(status.getUser().getBiggerProfileImageURL()); String cleanDate = status.getCreatedAt().toString(); date.add(cleanDate.substring(0, cleanDate.length() - 15) + " " + cleanDate.substring(cleanDate.length() - 4)); } } } catch (TwitterException e) { Log.e("exeption", e.toString()); } //loop teuth results and create array list for list view for (int i = 0; i < texts.size(); i++) { mTweetsInfo.add(new CreateTweet(titles.get(i), images.get(i), texts.get(i), date.get(i))); } } return mTweetsInfo; }
From source file:com.freedomotic.plugins.devices.twitter.gateways.TwitterGateway.java
License:Open Source License
public static synchronized Twitter getInstance(Config configuration) { if (twitter == null) { ConfigurationBuilder cb = new ConfigurationBuilder(); //TODO: create a default twitter account for freedom project. If the user do not customize the oauth parameters in //config file we can use by default the parameters of the freedom twitter account (the second argument in getStringProperty). cb.setDebugEnabled(true).setOAuthConsumerKey(configuration.getStringProperty("OAuthConsumerKey", null)) //"TLGtvoeABqf2tEG4itTUaw") .setOAuthConsumerSecret(configuration.getStringProperty("OAuthConsumerSecret", null)) //"nUJPxYR1qJmhX9SnWTBT0MzO7dIqUtNyVPfhg10wf0") .setOAuthAccessToken(configuration.getStringProperty("OAuthAccessToken", null))//"312792183-adnYVIv06spR4qsI3eKVv53CfrYHl3KqgtJtYm10") .setOAuthAccessTokenSecret(configuration.getStringProperty("OAuthAccessTokenSecret", null));//("Br2O2wtZ2dsLMDN21qKdlCLsOuqXW8h3z3uButRk"); TwitterFactory tf = new TwitterFactory(cb.build()); twitter = tf.getInstance(); }/*from www. j av a 2 s . co m*/ return twitter; }
From source file:com.freshdigitable.udonroad.module.TwitterApiModule.java
License:Apache License
@Singleton @Provides/*from w w w. j av a 2s . co m*/ public Twitter provideTwitter() { final TwitterFactory twitterFactory = new TwitterFactory(); final Twitter twitter = twitterFactory.getInstance(); final String key = context.getString(R.string.consumer_key); final String secret = context.getString(R.string.consumer_secret); twitter.setOAuthConsumer(key, secret); return twitter; }