我在我的项目中使用 spring-integration-twitter 4.1.6.RELEASE。使用 TwitterTemplate 我试图为经过身份验证的用户获取所有朋友。
所以我用这个方法,
friendsList = twitterTemplate.friendOperations().getFriends();
但在这种情况下,我只会得到 20 个朋友作为默认计数。但是我有 33 个朋友,我想把他们都带走。我该怎么做。当我调用此方法时,我也是经过身份验证的用户。在 TwitterTemplate 中,无法将计数作为参数传递。但 API 表示它将返回 5000 个用户。
/**
* Retrieves a list of up to 5000 users that the authenticated user follows.
* Note that this method make multiple calls to Twitter's REST API (one call to get a list of the friend IDs and one call for every 100 friends).
* If all you need is the friend IDs, consider calling getFriendIds() instead.
* Or if you need only a subset of the user's friends, call UserOperations.getUsers() passing in the list of friend IDs you need.
* @return a list of TwitterProfiles
* @throws ApiException if there is an error while communicating with Twitter.
* @throws MissingAuthorizationException if TwitterTemplate was not created with OAuth credentials.
*/
CursoredList<TwitterProfile> getFriends();
TwitterTemplate 调用 twitter API 来获取数据。所以请求重定向到 Twitter API 的https://api.twitter.com/1.1/friends/list.json
访问 URL。
目前,结果按最近的顺序排列——但是,此顺序可能会受到未宣布的更改和最终一致性问题的影响。结果以 20 个用户为一组给出,并且可以在后续请求中使用 next_cursor 值导航多个结果“页面”。有关详细信息,请参阅使用光标导航集合。
我怎样才能做到这一点???