Example usage for twitter4j Paging Paging

List of usage examples for twitter4j Paging Paging

Introduction

In this page you can find the example usage for twitter4j Paging Paging.

Prototype

public Paging(int page, long sinceId) 

Source Link

Usage

From source file:TwitterStats.Facade.Twitter.java

public Map<String, Integer> getTendencias(String user, int estudio) throws TwitterException {
    ResponseList res;/*from  w  ww . jav  a2 s.c om*/
    List<Status> lista = new ArrayList<>();
    Map<String, Integer> tendencias = new HashMap<>();

    for (int i = 1; i <= estudio / 200; i++) {
        res = twitter.getUserTimeline(user, new Paging(i, 200));
        lista.addAll(res);
    }

    for (Status status : lista) {
        HashtagEntity[] ht = status.getHashtagEntities();
        for (int i = 0; i < ht.length; i++) {
            String hash = ht[i].getText();
            if (tendencias.containsKey(hash)) {
                tendencias.put(hash, tendencias.get(hash) + 1);
            } else {
                tendencias.put(hash, 1);
            }
        }
    }

    return sortByValue(tendencias);
}

From source file:TwitterStats.Facade.Twitter.java

public Map<String, Integer> getMenciones(String user, int estudio) throws TwitterException {
    ResponseList res;/*  w  w w.j  a  va  2  s  .  c  om*/
    List<Status> lista = new ArrayList<>();
    Map<String, Integer> menciones = new HashMap<>();

    for (int i = 1; i <= estudio / 200; i++) {
        res = twitter.getUserTimeline(user, new Paging(i, 200));
        lista.addAll(res);
    }

    for (Status status : lista) {
        UserMentionEntity[] men = status.getUserMentionEntities();
        for (int i = 0; i < men.length; i++) {
            String mencion = men[i].getText();
            if (menciones.containsKey(mencion)) {
                menciones.put(mencion, menciones.get(mencion) + 1);
            } else {
                menciones.put(mencion, 1);
            }
        }
    }

    return sortByValue(menciones);
}

From source file:TwitterUserTimelineTweets.timeliner.java

public static void main(String[] args) throws JSONException, ParseException, InterruptedException {

    Postgresql.DBBaglan();/*w  w  w . j ava  2s  .co  m*/
    Postgresql.DBSelect();
    Twitter twitter = new TwitterFactory().getInstance();
    int pageno = 1;
    //String user = "gasanyasan";
    List statuses = new ArrayList();

    for (int i = 0; i < 5; i++) {
        System.out.println("ARANAN KULLANICI  :  " + sonuc[i]);
        while (true) {
            try {
                int size = statuses.size();
                Paging page = new Paging(pageno++, 100);
                statuses.addAll(twitter.getUserTimeline(sonuc[i], page));
                if (statuses.size() == size)

                    break;
            } catch (TwitterException e) {

                if (e.getErrorCode() == 88) {
                    System.out.println("SORGU LMT AILDI.....UYKUYA GRYOR...");
                    Thread.sleep(900000);

                }

                //e.printStackTrace();
            }
        }
    }

    for (Object statuse : statuses) {
        Status a = (Status) statuse;
        System.out.println(a.getText());
        System.out.println(a.getCreatedAt());
        System.out.println(a.getUser().getScreenName());
        System.out.println(a.getId());
    }

    System.out.println("Total: " + statuses.size());
    // System.out.println(stats.get(0).getText());     

}