Package twitter4j

Examples of twitter4j.RateLimitStatus


            throw new IllegalStateException("returned more than one user for screen name:" + twitter.getScreenName());
    }

    public int getSecondsUntilReset() {
        try {
            RateLimitStatus rls = twitter.getRateLimitStatus();
            rateLimit = rls.getRemainingHits();
            return rls.getSecondsUntilReset();
        } catch (TwitterException ex) {
            logger.error("Cannot determine rate limit:" + ex.getMessage());
            return -1;
        }
    }
View Full Code Here


    }
  }

  private void pullTweets(Key key, Twitter twitter) {
    try {
      RateLimitStatus rateLimitStatus = twitter.getRateLimitStatus();
      if (rateLimitStatus.getRemainingHits() == 0)
        return;

      double currentRate = (rateLimitStatus.getHourlyLimit() - rateLimitStatus
          .getRemainingHits())
          / (3601 - rateLimitStatus.getSecondsUntilReset());
      logger.info(
          "Current twitter refresh rate: {}/h, official refresh rate: {}",
          String.format("%1.1f", currentRate),
          rateLimitStatus.getHourlyLimit());
      if (currentRate > rateLimitStatus.getHourlyLimit()) {
        logger.info("Skipped refreshing Twitter feeds to limit the refresh rate");
        return;
      }

      ResponseList<Status> newFriendsTimeline = twitter.getHomeTimeline();
View Full Code Here

    public static void main(String[] args) {
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            Map<String ,RateLimitStatus> rateLimitStatus = twitter.getRateLimitStatus();
            for (String endpoint : rateLimitStatus.keySet()) {
                RateLimitStatus status = rateLimitStatus.get(endpoint);
                System.out.println("Endpoint: " + endpoint);
                System.out.println(" Limit: " + status.getLimit());
                System.out.println(" Remaining: " + status.getRemaining());
                System.out.println(" ResetTimeInSeconds: " + status.getResetTimeInSeconds());
                System.out.println(" SecondsUntilReset: " + status.getSecondsUntilReset());
            }
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to get rate limit status: " + te.getMessage());
View Full Code Here

TOP

Related Classes of twitter4j.RateLimitStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.