List of usage examples for twitter4j Twitter getUserListMembers
PagableResponseList<User> getUserListMembers(long listId, int count, long cursor) throws TwitterException;
From source file:org.loklak.scraper.TwitterRiver.java
License:Apache License
/** * Get users id of each list to stream them. * @param tUserlists List of user list. Should be a public list. * @return//from ww w .j a v a2 s. co m */ private long[] getUsersListMembers(String[] tUserlists) { logger.debug("Fetching user id of given lists"); List<Long> listUserIdToFollow = new ArrayList<Long>(); Configuration cb = buildTwitterConfiguration(); Twitter twitterImpl = new TwitterFactory(cb).getInstance(); //For each list given in parameter for (String listId : tUserlists) { logger.debug("Adding users of list {} ", listId); String[] splitListId = listId.split("/"); try { long cursor = -1; PagableResponseList<User> itUserListMembers; do { itUserListMembers = twitterImpl.getUserListMembers(splitListId[0], splitListId[1], cursor); for (User member : itUserListMembers) { long userId = member.getId(); listUserIdToFollow.add(userId); } } while ((cursor = itUserListMembers.getNextCursor()) != 0); } catch (TwitterException te) { logger.error("Failed to get list members for : {}", listId, te); } } //Just casting from Long to long long ret[] = new long[listUserIdToFollow.size()]; int pos = 0; for (Long userId : listUserIdToFollow) { ret[pos] = userId; pos++; } return ret; }
From source file:uk.co.flax.ukmp.twitter.PartyListHandler.java
License:Apache License
private Set<Long> readPartyIds(Twitter twitter, String screenName, String slug, String party) { Set<Long> ids = new HashSet<>(); try {/*ww w. java 2 s .co m*/ long cursor = -1; PagableResponseList<User> response = null; do { response = twitter.getUserListMembers(screenName, slug, cursor); for (User user : response) { LOGGER.debug("Read id for user @{}", user.getScreenName()); ids.add(user.getId()); } cursor = response.getNextCursor(); } while (response != null && response.hasNext()); } catch (TwitterException e) { LOGGER.error("Twitter exception updating {} party list : {}", party, e.getMessage()); } return ids; }