Advertisement
Guest User

twitter4j mention checker

a guest
Oct 26th, 2015
14
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import twitter4j.*;
  2.  
  3. public class main {
  4.     public static void main(String[] args)
  5.             throws TwitterException, InterruptedException {
  6.  
  7.         long newestID = 0;
  8.  
  9.         Twitter twitter = new Auth().getTwitter();
  10.  
  11.         long newestIDretrieved = 0;
  12.         while(true) {
  13.             ResponseList<Status> mentions = twitter.getMentionsTimeline();
  14.             newestIDretrieved = mentions.get(0).getId();
  15.             if (newestIDretrieved > newestID) {
  16.                 newestID = newestIDretrieved;
  17.                 System.out.println(mentions.get(0).getText());
  18.             }
  19.             Thread.sleep(1000*90); // check every 1.5 minutes. (limit is once per minute)
  20.         }
  21.  
  22.     }
  23. }
Advertisement
RAW Paste Data Copied
Advertisement