示例#1
0
 @Override
 public List<User> getUsers(final Twitter twitter) throws TwitterException {
   if (twitter == null) return null;
   final CursorPaging paging = new CursorPaging(getCount());
   if (getCursor() > 0) {
     paging.setCursor(getCursor());
   }
   final IDs ids = getIDs(twitter, paging);
   if (ids == null) return null;
   setCursorIds(ids);
   return twitter.lookupUsers(ids.getIDs());
 }
  private List<User> getUserDataFromTwitterID(long[] userIdList, String userName) {
    if (userIdList != null) {
      try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.setOAuthConsumer(consumerKey, consumerSecret);
        AccessToken accessToken = new AccessToken(accessTokenStr, accessTokenSecretStr);
        twitter.setOAuthAccessToken(accessToken);

        ResponseList<User> list = twitter.lookupUsers(userIdList);
        logger.info("Successfully looked up in Twitter by ID, size of list: " + list.size());
        return (list != null ? list : new ArrayList<User>());
      } catch (Exception e) {
        logger.error("Exception while getting user Data from TwitterId for user: " + userName, e);
      }
    }
    return new ArrayList<User>();
  }