这是我的代码:
package twitter;
import twitter4j.PagableResponseList;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.User;
import twitter4j.auth.AccessToken;
import twitter4j.conf.ConfigurationBuilder;
public class getFollowersIds {
public static final String CONSUMER_KEY = "PRIVATE";
public static final String CONSUMER_SECRET = "PRIVATE";
public static final String USER_ID = "PRIVATE";
public static final String ACCESS_TOKEN = "PRIVATE";
public static final String ACCESS_TOKEN_SECRET = "PRIVATE";
public static final int CURSOR = -1;
public static void main(String[] args) {
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
AccessToken oathAccessToken = new AccessToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
twitter.setOAuthAccessToken(oathAccessToken);
try {
PagableResponseList<User> users = twitter.getFriendsList(USER_ID, -1);
User user = null;
for (int i = 0 ; i < users.size() ; i++){
user = users.get(i);
System.out.println("Following: "+users.size());
System.out.print("\nID: "+user.getId()+" / User: "+user.getName()+" /");
System.out.print("\nFollowers: "+user.getFollowersCount()+"\n");
}
} catch (TwitterException e) {
e.printStackTrace();
}
}
}
这是错误行:
Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=7e95ed42 or
http://www.google.co.jp/search?q=45f34518
TwitterException{exceptionCode=[7e95ed42-45f34518], statusCode=404, message=Sorry, that page does not exist, code=34, retryAfter=-1, rateLimitStatus=RateLimitStatusJSONImpl{remaining=14, limit=15, resetTimeInSeconds=1411644615, secondsUntilReset=710}, version=4.0.2}
at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:163)
at twitter4j.HttpClientBase.request(HttpClientBase.java:53)
at twitter4j.HttpClientBase.get(HttpClientBase.java:71)
at twitter4j.TwitterImpl.get(TwitterImpl.java:1538)
at twitter4j.TwitterImpl.getFriendsList(TwitterImpl.java:479)
at twitter4j.TwitterImpl.getFriendsList(TwitterImpl.java:474)
at twitter.getFollowersIds.main(getFollowersIds.java:38)
需要帮助 不知道会发生什么......
&gt;中的错误PagableResponseList users = twitter.getFriendsList(USER_ID,-1);
由于
ThanksthanksthanksthanksthanksThanksthanksthanksthanksthanksThanksthanksthanksthanksthanksThanksthanksthanksthanksthanksThanksthanksthanksthanksthanks
答案 0 :(得分:2)
您的USER_ID应该是long而不是String。传递给twitter.getFriendsList()
的字符串用于屏幕名称。
此处有更多信息:http://twitter4j.org/javadoc/twitter4j/api/FriendsFollowersResources.html