List of usage examples for twitter4j.conf ConfigurationBuilder setDebugEnabled
public ConfigurationBuilder setDebugEnabled(boolean debugEnabled)
From source file:Jums.AllAPI.java
public static Configuration TwitterConnect() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true); cb.setOAuthConsumerKey(CONSUMERKEY); cb.setOAuthConsumerSecret(CONSUMERSECRET); cb.setOAuthAccessToken(TOKEN);/*from w w w . jav a 2 s .c o m*/ cb.setOAuthAccessTokenSecret(TOKENSECRET); return cb.build(); }
From source file:Jums.SearchTweet.java
public void main(PrintWriter out) { try {//from w ww.j av a 2 s . com ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true); cb.setOAuthConsumerKey(CONSUMERKEY); cb.setOAuthConsumerSecret(CONSUMERSECRET); cb.setOAuthAccessToken(TOKEN); cb.setOAuthAccessTokenSecret(TOKENSECRET); Twitter tw = new TwitterFactory(cb.build()).getInstance(); User user = tw.verifyCredentials(); List<Status> statuses = tw.getHomeTimeline(); for (Status s : statuses) { } } catch (Exception e) { e.printStackTrace(); } }
From source file:junit.org.rapidpm.module.iot.twitter.TwitterInitApp.java
License:Apache License
public static void main(String[] args) throws TwitterException { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("DI0UZvexwirEJ1wl5sw9Vfqx3") .setOAuthConsumerSecret("NQ0Zumw7Li1XbuwzrNHOKquznBgmAJo1sPAoqiNMShqgFufqip") .setOAuthAccessToken("2440296835-4dmuWPOLYUgLjn9ddcXpuloOgDAPO1W0Y5NZSg7") .setOAuthAccessTokenSecret("X9QYzlDKURIxGZbFWoZ7NdvhcFurBfEUVHMTLxtBSrU2x"); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance();/*from ww w.j a v a 2 s. c o m*/ twitter.getHomeTimeline().forEach(s -> System.out.println("s.getText() = " + s.getText())); }
From source file:keypoh.TwitterCrawler.java
/** * Procedure Configure/*from w w w . j ava 2 s .c om*/ * Configure Twitter API * * @param config */ private void Configure(twitter4j.conf.ConfigurationBuilder config) { config.setDebugEnabled(true).setApplicationOnlyAuthEnabled(true).setHttpProxyHost("167.205.22.104") .setHttpProxyPort(8082); }
From source file:libreriatwitter.Metodos.java
/** * Mtodo para acceder a la cuenta con los datos que nos da Twitter Apps *//* w w w. ja va 2s .c om*/ 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: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 ww .java2 s.c o m*/ //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:my.twittergui.TwitterUI.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed String text;//from w ww . j av a 2 s . co m text = jTextField1.getText(); //jTextArea1.append(text+"\n"); jTextArea1.append("Searching for: "); String[] strarray = text.split(" "); for (int i = 0; i < strarray.length; i++) { jTextArea1.append(strarray[i] + "\n"); } File filed = null; filed = new File("C:\\Results"); if (!filed.exists()) { filed.mkdir(); } ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true).setOAuthConsumerKey("").setOAuthConsumerSecret("").setOAuthAccessToken("") .setOAuthAccessTokenSecret(""); StatusListener listener = new StatusListener() { public void onStatus(Status status) { try { int fileno = 0; String strI = Integer.toString(fileno); String fname = "C:\\results\\DataCol" + strI + ".csv"; File file = new File(fname); FileWriter bw = new FileWriter(file, true); if (file.length() == 0) { bw.write("\"Screen Name\", text, \"created at\", geolocation, Retweet? \r\n"); bw.flush(); } while (file.length() > 10485760) { fileno += 1; strI = Integer.toString(fileno); fname = "DataCol" + strI + ".txt"; file = new File(fname); bw = new FileWriter(file, true); bw.write("\"Screen Name\", \"text\", \"created_at\", \"geolocation\" \r\n"); bw.flush(); } // if(!status.isRetweet()){ bw.write("\r\n"); bw.write("\"" + status.getUser().getScreenName() + "\","); String tweettxt = status.getText(); tweettxt = tweettxt.replace("\n", ""); tweettxt = tweettxt.replace(",", ""); tweettxt = tweettxt.replace("\"", ""); bw.write("\"" + tweettxt + "\","); bw.write("\"" + status.getCreatedAt() + "\","); if (status.getGeoLocation() != null) { bw.write("\"" + status.getGeoLocation() + "\""); } else bw.write("N/A,"); if (status.isRetweet()) bw.write("Yes"); else bw.write("No"); bw.flush(); bw.close(); //System.out.print("\n"); String str = "@" + status.getUser().getScreenName() + " " + status.getText() + " " + status.getCreatedAt() + " "; if (status.getGeoLocation() != null) str += status.getGeoLocation(); //System.out.print(str); jTextArea1.append(str + "\n"); // } bw.close(); } catch (IOException e) { //System.out.print("EXCEPTION"); e.printStackTrace(); } } public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { } public void onTrackLimitationNotice(int numberOfLimitedStatuses) { } public void onStallWarning(StallWarning stall) { } public void onScrubGeo(long a, long b) { } public void onException(Exception ex) { ex.printStackTrace(); } }; TwitterStreamFactory tf = new TwitterStreamFactory(cb.build()); TwitterStream twitterStream = tf.getInstance(); twitterStream.addListener(listener); // Filter FilterQuery filtre = new FilterQuery(); Scanner in = new Scanner(System.in); filtre.track(strarray); twitterStream.filter(filtre); }
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 w w .ja v a 2 s . c om 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.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 . j a v a2 s. c om 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;// ww w .j a va2s . c om 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(); }