List of usage examples for twitter4j IDs getNextCursor
@Override
long getNextCursor();
From source file:twitterrest.Followersids.java
License:Apache License
static List<Long> followers(Twitter twitter, String screenName) { List<Long> m_FollowersList = new ArrayList<Long>(); long cursor = -1; //int count = 0; while (true) { IDs ids = null; try {/*ww w. j a va 2s. co m*/ //IDs ids = twitter.getFollowersIDs(user.getId(), cursor); ids = twitter.getFollowersIDs(screenName, cursor); } catch (TwitterException twitterException) { // Rate Limit ????????? // () status code ????????? RateLimitStatus rateLimit = twitterException.getRateLimitStatus(); int secondsUntilReset = rateLimit.getSecondsUntilReset(); System.err.println("please wait for " + secondsUntilReset + " seconds"); System.err.println("Reset Time : " + rateLimit.getResetTimeInSeconds()); //() 120?getSecondsUntilReset() ???? //????????? long waitTime = (long) (secondsUntilReset + 120) * 1000; //long waitTime = (long)(300 * 1000); // 300? try { Thread.sleep(waitTime); } catch (Exception e) { e.printStackTrace(); } continue; } catch (Exception e) { e.printStackTrace(); } long[] idArray = ids.getIDs(); for (int i = 0; i < idArray.length; i++) { //System.out.println("["+(++count)+"]" + idArray[i]); m_FollowersList.add(new Long(idArray[i])); } if (ids.hasNext()) { cursor = ids.getNextCursor(); } else { break; } } return m_FollowersList; }
From source file:twittterbot08.TwittterBot08.java
public ArrayList<Long> getFollowerIDs(String screenName) throws TwitterException { ArrayList<Long> result = new ArrayList(); long cursor = -1; IDs ids; do {//from w w w . j a va 2 s .com ids = twitter.getFollowersIDs(screenName, cursor); for (long id : ids.getIDs()) { result.add(id); } } while ((cursor = ids.getNextCursor()) != 0); return result; }
From source file:uniandes.cupi2.tweetSpy.mundo.TweeSpy.java
License:Academic Free License
/** * Retorna la lista de amigos del usuario. * @return// ww w.ja v a 2s.c om * @throws TwitterException */ public ListaDoblementeEncadenada<Usuario> darListaAmigos() throws TwitterException { listaAmigos = new ListaDoblementeEncadenada<Usuario>(); User u1 = null; long cursor = -1; IDs ids; String resp = user.getScreenName(); do { ids = user.getFriendsIDs(resp, cursor); for (long id : ids.getIDs()) { //System.out.println(id); User useri = user.showUser(id); String nombre = useri.getName(); String name = useri.getScreenName(); String url = useri.getOriginalProfileImageURL(); String desc = useri.getDescription(); //Para buscaar por indices ResponseList<Status> estatuses = user.getUserTimeline(name); Usuario nuevoAmigo = new Usuario(nombre, url, desc); nuevoAmigo.recibirTimeline(estatuses); listaAmigos.agregarFinal(nuevoAmigo); // contenedor? } } while ((cursor = ids.getNextCursor()) != 0); return listaAmigos; }
From source file:uniandes.cupi2.tweetSpy.mundo.TweeSpy.java
License:Academic Free License
/** * Retorna la lista de seguidores del usuario. *///from w w w . ja va 2s. co m public ListaDoblementeEncadenada<Usuario> darListaSeguidores() throws TwitterException { listaSeguidores = new ListaDoblementeEncadenada<Usuario>(); User u1 = null; long cursor = -1; IDs ids; String resp = user.getScreenName(); do { ids = user.getFollowersIDs(resp, cursor); for (long id : ids.getIDs()) { //System.out.println(id); User useri = user.showUser(id); String nombre = useri.getName(); String url = useri.getOriginalProfileImageURL(); String desc = useri.getDescription(); Usuario nuevoAmigo = new Usuario(nombre, url, desc); listaSeguidores.agregarFinal(nuevoAmigo); // contenedor? } } while ((cursor = ids.getNextCursor()) != 0); return listaSeguidores; }