List of usage examples for twitter4j TwitterFactory TwitterFactory
public TwitterFactory(String configTreePath)
From source file:kr.debop4j.search.twitter.Twitters.java
License:Apache License
public synchronized static Twitter getTwitter() { if (twitter == null) { twitter = new TwitterFactory(getConfiguration()).getInstance(); }/*from w ww . jav a2s. c om*/ return twitter; }
From source file:libreriatwitter.Metodos.java
/** * Mtodo para acceder a la cuenta con los datos que nos da Twitter Apps *///from w w w. j a v a2 s . c o m public Metodos() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("5zO44Aeo4gLC52fvhqaocpU9P") .setOAuthConsumerSecret("0u0YwQrnI5OG4ZpactT4Vyl9eNJbVBdKPhbLOghrCH6sHefcwh") .setOAuthAccessToken("182041479-hoD2StntYm3bdCDQFMjueknzKf5YhGIS9OnZNS37") .setOAuthAccessTokenSecret("hocHHSwrb0WFbl6g4JI6UdqY9VEUZT3mRqG0ANCU7Jzao"); twitter = new TwitterFactory(cb.build()).getInstance(); twitter = new TwitterFactory("twitter4j.properties").getInstance(); }
From source file:log4twitter.TwitterWrapper.java
License:Apache License
private void initTwitter() { twitter = null;/* ww w .ja v a 2 s. com*/ asyncTwitter = null; if (this.async) { asyncTwitter = new AsyncTwitterFactory("/log4twitter").getInstance(); } else { twitter = new TwitterFactory("/log4twitter").getInstance(); } }
From source file:Logic.mongoC.java
public boolean conect() { try {//from w ww .jav a 2 s . c om cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("JdGDNmMv8tAkKsETMCY7DZHKb") .setOAuthConsumerSecret("3FPCYWtVjbXcR1uJa2r26vvTBUWZaTL6Y7sMkGlnir1dZOcPSi") .setOAuthAccessToken("306043744-RpbVQtTG0cpZ3c2ItfN2QaruVEmliJ24B5NVnLjz") .setOAuthAccessTokenSecret("mOjCZi44GTWW7ELNaVRow4o9JBU3dqTZQCLPPGXNRg4bP"); factory = new TwitterFactory(cb.build()); twitter = factory.getInstance(); mc = new MongoClient(); db = mc.getDatabase("social_media"); coll = db.getCollection("Usuarios"); this.gson = new GsonBuilder().setPrettyPrinting().create(); return true; } catch (Exception ex) { return false; } }
From source file:MainScreen.Display.java
/** * Creates new form Display/*from w w w . ja v a 2 s . c om*/ */ public Display() { initComponents(); //TWITTER INIT cb.setOAuthConsumerKey("3I1RTnsA7JhWgnbomQuYrEhmP"); cb.setOAuthConsumerSecret("tNvpM739osUCRtTjDT47Yifbc4OB5mvxXWsKLld4lGRvn1X4SU"); cb.setOAuthAccessToken("743138963767107584-3MZxk0Et5tmBhDXHWAppmHlyiPO5OW4"); cb.setOAuthAccessTokenSecret("QaQPydUPRdH8SicXDVoIU13dSq5NKOxcloJlX1ZYYkrCO"); twitter = new TwitterFactory(cb.build()).getInstance(); try { statuses = twitter.getHomeTimeline(); displayTweets(); } catch (TwitterException ex) { Logger.getLogger(Display.class.getName()).log(Level.SEVERE, null, ex); } t = new Timer(refreshRate, new TimerListener()); t.start(); //WEATHER INIT c = Calendar.getInstance(); // Creates a calander object day = c.get(Calendar.DAY_OF_WEEK); displayWeather(); }
From source file:mashup.MashTweetManager.java
public static ArrayList<String> getTweets(String topic) throws IOException { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthAccessToken(Common.AccessToken) .setOAuthAccessTokenSecret(Common.AccessTokenSecret).setOAuthConsumerKey(Common.ConsumerKey) .setOAuthConsumerSecret(Common.ConsumerSecret); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance();/* w w w . jav a2 s . c om*/ //Twitter twitter = new TwitterFactory().getInstance(); // twitter.setOAuthAccessToken(null); ArrayList<String> tweetList = new ArrayList<>(); try { Query query = new Query(topic.toLowerCase().trim()); query.setCount(100); query.setLocale("en"); query.setLang("en"); QueryResult result = null; do { result = twitter.search(query); List<Status> tweets = result.getTweets(); for (Status tweet : tweets) { String data = tweet.getText().replaceAll("[^\\p{L}\\p{Z}]", ""); HinghlishStopWords.removeStopWords(data.trim()); // Remove Special... Characters // Remove stop words tweetList.add(tweet.getText().replaceAll("[^\\p{L}\\p{Z}]", "")); } } while ((query = result.nextQuery()) != null); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to search tweets: " + te.getMessage()); } return tweetList; }
From source file:net.archenemy.archenemyapp.model.TwitterAdapter.java
License:Apache License
private Twitter getAuthorizedTwitterInstance(Context context) { TwitterAuthToken authToken = com.twitter.sdk.android.Twitter.getSessionManager().getActiveSession() .getAuthToken();//from w ww . j ava2 s. co m ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.setDebugEnabled(true).setOAuthConsumerKey(getKey(context)) .setOAuthConsumerSecret(getSecret(context)).setOAuthAccessToken(authToken.token) .setOAuthAccessTokenSecret(authToken.secret); return new TwitterFactory(configurationBuilder.build()).getInstance(); }
From source file:net.codestory.http.filters.twitter.TwitterAuthFilter.java
License:Apache License
private static Authenticator createAuthenticator(String oAuthKey, String oAuthSecret) { Configuration config = new ConfigurationBuilder().setOAuthConsumerKey(oAuthKey) .setOAuthConsumerSecret(oAuthSecret).build(); TwitterFactory twitterFactory = new TwitterFactory(config); return new TwitterAuthenticator(twitterFactory); }
From source file:net.hekatoncheir.speechtweet.SpeechTweet.java
License:Apache License
private boolean verifyCredentials() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); String accessToken = sharedPreferences.getString("accessToken", null); String accessTokenSecret = sharedPreferences.getString("accessTokenSecret", null); if (accessToken == null || accessTokenSecret == null) return false; // Read configuration ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(mOAuthConsumerKey).setOAuthConsumerSecret(mOAuthConsumerSecret) .setOAuthAccessToken(accessToken).setOAuthAccessTokenSecret(accessTokenSecret); ///*w w w .ja v a 2 s . com*/ mIsVerifyCredentials = true; mRingPlayer = MediaPlayer.create(SpeechTweet.this, R.raw.ring); mRingPlayer.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { if (mIsVerifyCredentials) { mRingPlayer.start(); } } }); mRingPlayer.start(); showMessage(R.string.message_ring); TwitterFactory factory = new TwitterFactory(cb.build()); mTwitter = factory.getInstance(); new Thread(new Runnable() { @Override public void run() { User user = null; try { user = mTwitter.verifyCredentials(); } catch (TwitterException e) { } final User u = user; mHandler.post(new Runnable() { public void run() { SpeechTweet.this.finishVerifyCredentials(u); } }); } }).start(); return true; }
From source file:net.hekatoncheir.speechtweet.SpeechTweet.java
License:Apache License
private void startOAuth() { mIsOpenOAuth = true;/* www. java2s .c o m*/ ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey(mOAuthConsumerKey) .setOAuthConsumerSecret(mOAuthConsumerSecret); TwitterFactory factory = new TwitterFactory(cb.build()); mTwitter = factory.getInstance(); new Thread(new Runnable() { @Override public void run() { Boolean isSuccess = false; try { mRequestToken = mTwitter.getOAuthRequestToken(mOAuthCallbackURL); isSuccess = true; } catch (TwitterException e) { } final Boolean s = isSuccess; mHandler.post(new Runnable() { public void run() { SpeechTweet.this.finishGetOAuthRequestToken(s); } }); } }).start(); }