twitter4j.Twitter.getFollowersIDs()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中twitter4j.Twitter.getFollowersIDs()方法的一些代码示例,展示了Twitter.getFollowersIDs()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Twitter.getFollowersIDs()方法的具体详情如下:
包路径:twitter4j.Twitter
类名称:Twitter
方法名:getFollowersIDs

Twitter.getFollowersIDs介绍

[英]Returns an array of numeric IDs for every user the specified user is followed by.
[中]返回指定用户后跟的每个用户的数字ID数组。

代码示例

代码示例来源:origin: loklak/loklak_server

collect: while (cursor != 0) {
  try {
    IDs ids = networkRelation == Networker.FOLLOWERS ? twitter.getFollowersIDs(screen_name, cursor) : twitter.getFriendsIDs(screen_name, cursor);
    RateLimitStatus rateStatus = ids.getRateLimitStatus();
    if (networkRelation == Networker.FOLLOWERS) {

代码示例来源:origin: net.homeip.yusuke/twitter4j

/**
 * Returns an array of numeric IDs for every user the specified user is followed by.
 * @param userId Specfies the ID of the user for whom to return the followers list.
 * @return The ID or screen_name of the user to retrieve the friends ID list for.
 * @throws TwitterException when Twitter service or network is unavailable
 * @since Twitter4J 2.0.0
 * @see <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-followers%C2%A0ids">Twitter API Wiki / Twitter REST API Method: followers ids</a>
 */
public IDs getFollowersIDs(int userId) throws TwitterException {
  return getFollowersIDs(userId, -1l);
}

代码示例来源:origin: net.homeip.yusuke/twitter4j

/**
 * Returns an array of numeric IDs for every user the specified user is followed by.
 * @return The ID or screen_name of the user to retrieve the friends ID list for.
 * @throws TwitterException when Twitter service or network is unavailable
 * @since Twitter4J 2.0.0
 * @see <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-followers%C2%A0ids">Twitter API Wiki / Twitter REST API Method: followers ids</a>
 */
public IDs getFollowersIDs() throws TwitterException {
  return getFollowersIDs(-1l);
}

代码示例来源:origin: net.homeip.yusuke/twitter4j

/**
 * Returns an array of numeric IDs for every user the specified user is followed by.
 * @param screenName Specfies the screen name of the user for whom to return the followers list.
 * @return The ID or screen_name of the user to retrieve the friends ID list for.
 * @throws TwitterException when Twitter service or network is unavailable
 * @since Twitter4J 2.0.0
 * @see <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-followers%C2%A0ids">Twitter API Wiki / Twitter REST API Method: followers ids</a>
 */
public IDs getFollowersIDs(String screenName) throws TwitterException {
  return getFollowersIDs(screenName, -1l);
}

代码示例来源:origin: stackoverflow.com

Twitter myTwitter = new TwitterFactory().getInstance();
long[] followerIds = myTwitter.getFollowersIDs("screenName", -1).getIDs();

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    IDs ids = twitter.getFollowersIDs(cursor);
    for (TwitterListener listener : listeners) {
      try {
        listener.gotFollowersIDs(ids);
      } catch (Exception e) {
        logger.warn("Exception at getFollowersIDs", e);
      }
    }
  }
});

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    IDs ids = twitter.getFollowersIDs(screenName, cursor);
    for (TwitterListener listener : listeners) {
      try {
        listener.gotFollowersIDs(ids);
      } catch (Exception e) {
        logger.warn("Exception at getFollowersIDs", e);
      }
    }
  }
});

代码示例来源:origin: org.twitter4j/twitter4j-async

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    IDs ids = twitter.getFollowersIDs(userId, cursor);
    for (TwitterListener listener : listeners) {
      try {
        listener.gotFollowersIDs(ids);
      } catch (Exception e) {
        logger.warn("Exception at getFollowersIDs", e);
      }
    }
  }
});

代码示例来源:origin: stackoverflow.com

try {
       Twitter twitter = new TwitterFactory().getInstance();
       long cursor = -1;
       IDs ids;
       System.out.println("Listing followers's ids.");
       do {
         if (0 < userId) {
           ids = twitter.getFollowersIDs(userId, cursor);
         } else {
           ids = twitter.getFollowersIDs(cursor);
         }
         for (long id : ids.getIDs()) {
           System.out.println(id);
         }
       } while ((cursor = ids.getNextCursor()) != 0);
       System.exit(0);
     } catch (TwitterException te) {
       te.printStackTrace();
       System.out.println("Failed to get followers' ids: " + te.getMessage());
       System.exit(-1);
     }

代码示例来源:origin: stackoverflow.com

TwitterFactory factory = new TwitterFactory();
 Twitter twitter = factory.getInstance();
 String twitterScreenName;
 try {
   twitterScreenName = twitter.getScreenName();
 IDs followerIDs = twitter.getFollowersIDs(twitterScreenName, -1);
 long[] ids = followerIDs.getIDs();
 for (long id : ids) {
   twitter4j.User user = twitter.showUser(id);
   //here i am trying to fetch the followers of each id
   String userScreenName = user.getScreenName();
   System.out.println("Name: " + user.getScreenName());
   System.out.println("Location:" + user.getLocation());
   IDs followerIDsOfFollowers = twitter.getFollowersIDs(user.getScreenName(), -1);
   long[]fofIDs = followerIDsOfFollowers.getIDs();
   for(long subId : fofIDs) {
     twitter4j.User user1 = twitter.showUser(subId);
     System.out.println("Follower Master:" + userScreenName +" Follower of Follower Name: " + user1.getScreenName());
     System.out.println("Location:" + user1.getLocation());
   }

代码示例来源:origin: jchampemont/WTFDYUM

@Override
public Set<Long> getFollowers(final Long userId, final Optional<Principal> principal) throws WTFDYUMException {
  Preconditions.checkNotNull(userId);
  final Twitter twitter = principal.isPresent() ? twitter(principal.get()) : twitter();
  final Set<Long> result = new HashSet<>();
  try {
    IDs followersIDs = null;
    long cursor = -1;
    do {
      followersIDs = twitter.getFollowersIDs(userId, cursor);
      if(followersIDs.hasNext()) {
        cursor = followersIDs.getNextCursor();
        checkRateLimitStatus(followersIDs.getRateLimitStatus(),
          WTFDYUMExceptionType.GET_FOLLOWERS_RATE_LIMIT_EXCEEDED);
      }
      final Set<Long> currentFollowers = Arrays.stream(followersIDs.getIDs()).boxed()
          .collect(Collectors.toCollection(() -> new HashSet<>()));
      result.addAll(currentFollowers);
    } while (followersIDs.hasNext());
  } catch (final TwitterException e) {
    log.debug("Error while getFollowers", e);
    throw new WTFDYUMException(e, WTFDYUMExceptionType.TWITTER_ERROR);
  }
  return result;
}

代码示例来源:origin: stackoverflow.com

System.out.println("Listing followers's ids.");
do {
  ids = twitter.getFollowersIDs("SrBachchan", cursor);
  for (long id : ids.getIDs()) {
    System.out.println(id);

相关文章