Package twitter4j

Examples of twitter4j.IDs


    private static int MAX_FRIEND_RET = 10;

    public void init() throws TwitterException {
        // twitter = TwitterFactory.getInstance(userName, password);
        IDs friendids = twitter.getFriendsIDs();
        IDs followersids = twitter.getFollowersIDs();
        PagableResponseList<User> friendsStatuses =  twitter.getFriendsStatuses();
    }
View Full Code Here


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof IDs)) return false;

        IDs iDs = (IDs) o;

        if (!Arrays.equals(ids, iDs.getIDs())) return false;

        return true;
    }
View Full Code Here

                resetRateLimitCache();
                myWait(0.5f);
            }

            ResponseList res = null;
            IDs ids = null;
            try {
                if (friends)
                    ids = twitter.getFriendsIDs(userName, cursor);
                else
                    ids = twitter.getFollowersIDs(userName, cursor);

                rateLimit--;
            } catch (TwitterException ex) {
                logger.warn(ex.getMessage());
                break;
            }
            if (ids.getIDs().length == 0)
                break;

            long[] intids = ids.getIDs();

            // split into max 100 batch           
            for (int offset = 0; offset < intids.length; offset += 100) {
                long[] limitedIds = new long[100];
                for (int ii = 0; ii + offset < intids.length && ii < limitedIds.length; ii++) {
                    limitedIds[ii] = intids[ii + offset];
                }

                // retry at max N times for every id bunch
                for (int i = 0; i < 5; i++) {
                    try {
                        res = twitter.lookupUsers(limitedIds);
                        rateLimit--;
                        for (Object o : res) {
                            User user = (User) o;
                            // strange that this was necessary for ibood
                            if (user.getScreenName().trim().isEmpty())
                                continue;

                            JUser jUser = new JUser(user);
                            if (executor.execute(jUser) == null)
                                break MAIN;
                        }
                        break;
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        myWait(5);
                        continue;
                    }
                }

                if (res == null) {
                    logger.error("giving up");
                    break;
                }
            }

            if (!ids.hasNext())
                break;

            cursor = ids.getNextCursor();
        }
    }
View Full Code Here

    public synchronized List<User> getFollowees(final User user,
                                                final int limit) throws TwitterClientException {
        List<User> users = new LinkedList<User>();

        IDs ids;
        long cursor = -1;
        int total = 0;

        do {
            LOGGER.info("finding followees of user " + user + " (cursor = " + cursor + ")");

            ids = null;
            while (null == ids) {
                try {
                    ids = twitter.friendsFollowers().getFriendsIDs(user.getId(), cursor);
                } catch (TwitterException e) {
                    checkProtected(user, e);

                    rateLimiter.handle(e);
                }
            }

            for (long id : ids.getIDs()) {
                users.add(new User(id));

                if (limit > 0 && ++total >= limit) {
                    // if the limit is reached, exit early
                    return users;
                }
            }
        } while ((cursor = ids.getNextCursor()) != 0);

        return users;
    }
View Full Code Here

    public synchronized List<User> getFollowers(final User user,
                                                final int limit) throws TwitterClientException {
        List<User> users = new LinkedList<User>();

        IDs ids;
        long cursor = -1;
        int total = 0;

        do {
            LOGGER.info("finding followers of user " + user + " (cursor = " + cursor + ")");

            ids = null;
            while (null == ids) {
                try {
                    ids = twitter.friendsFollowers().getFollowersIDs(user.getId(), cursor);
                } catch (TwitterException e) {
                    checkProtected(user, e);

                    rateLimiter.handle(e);
                }
            }

            for (long id : ids.getIDs()) {
                users.add(new User(id));

                if (limit > 0 && ++total >= limit) {
                    // if the limit is reached, exit early
                    return users;
                }
            }
        } while ((cursor = ids.getNextCursor()) != 0);

        return users;
    }
View Full Code Here

           
  public static void followers()
  {
     try {
             long cursor = -1;
             IDs ids;
             System.out.println("Listing following ids.");
             do {
                  //////////ids = twitter.getFriendsIDs(cursor);
                  ids = twitter.getFollowersIDs(1);   //PERE
                  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 friends' ids: " + te.getMessage());
              System.exit(-1);
View Full Code Here

     */
    public static void main(String[] args) {
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            long cursor = -1;
            IDs ids;
            System.out.println("Showing incoming pending follow request(s).");
            do {
                ids = twitter.getIncomingFriendships(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 incoming friendships: " + te.getMessage());
            System.exit(-1);
View Full Code Here

     */
    public static void main(String[] args) {
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            long cursor = -1;
            IDs ids;
            System.out.println("Showing outgoing pending follow request(s).");
            do {
                ids = twitter.getOutgoingFriendships(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 outgoing friendships: " + te.getMessage());
            System.exit(-1);
View Full Code Here

     */
    public static void main(String[] args) {
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            long cursor = -1;
            IDs ids;
            System.out.println("Listing followers's ids.");
            do {
                if (0 < args.length) {
                    ids = twitter.getFollowersIDs(args[0], 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);
View Full Code Here

     */
    public static void main(String[] args) {
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            long cursor = -1;
            IDs ids;
            System.out.println("Listing following ids.");
            do {
                if (0 < args.length) {
                    ids = twitter.getFriendsIDs(args[0], cursor);
                } else {
                    ids = twitter.getFriendsIDs(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 friends' ids: " + te.getMessage());
            System.exit(-1);
View Full Code Here

TOP

Related Classes of twitter4j.IDs

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.