Twitter unauthenticatedTwitter = new TwitterFactory().getInstance(); //First param of Paging() is the page number, second is the number per page (this is capped around 200 I think. Paging paging = new Paging(1, 100); List<Status> statuses = unauthenticatedTwitter.getUserTimeline("google",paging);
public Paging maxId(long maxId) { setMaxId(maxId); return this; } }
protected Paging getPaging(int page, int count, long sinceId) { Paging paging = new Paging(page, count); if (sinceId > 0) { paging.setSinceId(sinceId); } return paging; }
/** * Converts the pagination parameters into a List of PostParameter.<br> * This method also Validates the preset parameters, and throws * IllegalStateException if any unsupported parameter is set. * * @param supportedParams char array representation of supported parameters * @param perPageParamName name used for per-page parameter. getUserListStatuses() requires "per_page" instead of "count". * @return list of PostParameter */ /*package*/ List<HttpParameter> asPostParameterList(char[] supportedParams, String perPageParamName) { java.util.List<HttpParameter> pagingParams = new ArrayList<HttpParameter>(supportedParams.length); addPostParameter(supportedParams, 's', pagingParams, "since_id", getSinceId()); addPostParameter(supportedParams, 'm', pagingParams, "max_id", getMaxId()); addPostParameter(supportedParams, 'c', pagingParams, perPageParamName, getCount()); addPostParameter(supportedParams, 'p', pagingParams, "page", getPage()); if (pagingParams.size() == 0) { return NULL_PARAMETER_LIST; } else { return pagingParams; } }
/** * Returns the 20 most recent statuses posted in the last 24 hours from the authenticating user. * <br>This method calls http://twitter.com/statuses/friends_timeline * * @param sinceId Returns only statuses with an ID greater than (that is, more recent than) the specified ID * @param page the number of page * @return list of the Friends Timeline * @throws TwitterException when Twitter service or network is unavailable * @since Twitter4J 1.1.8 * @deprecated Use getFriendsTimeline(Paging paging) instead * @see <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-friends_timeline">Twitter API Wiki / Twitter REST API Method: statuses friends_timeline</a> */ public List<Status> getFriendsTimeline(long sinceId, int page) throws TwitterException { return getFriendsTimeline(new Paging(page).sinceId(sinceId)); }
/** * Asynchronously requests loading of tweets prior to the given status. * * @param loadUntilThisStatus the status whose prior tweets are requested */ public void loadMoreTweets(final long loadUntilThisStatus) { CompletableFuture.runAsync(() -> { getLocalLogger().debug("Requesting more tweets."); final Paging requestPaging = new Paging(); requestPaging.setMaxId(loadUntilThisStatus); sessionManager.getCurrentTwitter() .mapTry(twitter -> backfillLoad(twitter, requestPaging)) .onSuccess(this::addTweets); getLocalLogger().debug("Finished loading more tweets."); }); }
public Paging(int page, int count, long sinceId) { this(page, count); setSinceId(sinceId); }
@Override protected List<Status> doPoll() throws TwitterException { Paging paging = getLastIdPaging(); log.trace("doPoll.getUserTimeline(user={}, sinceId={})", user, paging.getSinceId()); return getTwitter().getUserTimeline(user, paging); }
public Paging count(int count) { setCount(count); return this; }
public Paging(int page) { setPage(page); }
/** * Returns the most recent statuses posted in the last 24 hours from the specified user id. * <br>This method calls http://twitter.com/statuses/user_timeline * @param id String * @param count int * @param listener a listener object that receives the response * @see <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method:-statuses-user_timeline">Twitter API Wiki / Twitter REST API Method: statuses user_timeline</a> * @deprecated Use getUserTimelineAsync(String id, Paging paging, TwitterListener listener) instead */ public void getUserTimelineAsync(String id, int count, TwitterListener listener) { getUserTimelineAsync(id, new Paging().count(count), listener); }
/** * Converts the pagination parameters into a List of PostParameter.<br> * This method also Validates the preset parameters, and throws * IllegalStateException if any unsupported parameter is set. * * @param supportedParams char array representation of supported parameters * @param perPageParamName name used for per-page parameter. getUserListStatuses() requires "per_page" instead of "count". * @return list of PostParameter */ /*package*/ HttpParameter[] asPostParameterArray(char[] supportedParams, String perPageParamName) { java.util.List<HttpParameter> pagingParams = new ArrayList<HttpParameter>(supportedParams.length); addPostParameter(supportedParams, 's', pagingParams, "since_id", getSinceId()); addPostParameter(supportedParams, 'm', pagingParams, "max_id", getMaxId()); addPostParameter(supportedParams, 'c', pagingParams, perPageParamName, getCount()); addPostParameter(supportedParams, 'p', pagingParams, "page", getPage()); if (pagingParams.size() == 0) { return NULL_PARAMETER_ARRAY; } else { return pagingParams.toArray(new HttpParameter[pagingParams.size()]); } }
/** * Returns a list of the direct messages sent to the authenticating user. * <br>This method calls http://twitter.com/direct_messages * * @param page the number of page * @param sinceId Returns only direct messages with an ID greater than (that is, more recent than) the specified ID. * @return List * @throws TwitterException when Twitter service or network is unavailable * @since Twitter4J 2.0.0 * @deprecated Use getDirectMessages(Paging paging) instead * @see <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-direct_messages">Twitter API Wiki / Twitter REST API Method: direct_messages</a> */ public List<DirectMessage> getDirectMessages(int page , int sinceId) throws TwitterException { return getDirectMessages(new Paging(page).sinceId(sinceId)); }
public Paging sinceId(long sinceId) { setSinceId(sinceId); return this; }
@Override protected List<Status> doPoll() throws TwitterException { Paging paging = getLastIdPaging(); log.trace("doPoll.getRetweetsOfMe(sinceId={})", paging.getSinceId()); return getTwitter().getRetweetsOfMe(paging); }
public Paging(int page, int count) { this(page); setCount(count); } public Paging(int page, long sinceId) {