problem with getRetweeters with Jtwitter
my piece of code is:
for(int i=0;i<list.size();i++){
listRetweeters = null;
tweetId = list.get(i).getId();
status = twitter.getStatus(tweetId);
listRetweeters= twitter.getRetweeters(status);
开发者_运维问答 System.out.println("users RT: ");
for(int j=0;j<listRetweeters.size();j++)
System.out.println(listRetweeters.get(j).toString());
}
my problem is that at try retweeters of a tweet my return this error:
Exception in thread "main" winterwell.jtwitter.TwitterException$E401: Unauthorized HTTP/1.1 401 Unauthorized {"errors":[{"code":32,"message":"Could not authenticate you"}]} http://api.twitter.com/1/statuses/111580420944044034/retweeted_by.json (anonymous) at winterwell.jtwitter.URLConnectionHttpClient.processError(URLConnectionHttpClient.java:380) at winterwell.jtwitter.URLConnectionHttpClient.connect(URLConnectionHttpClient.java:199) at winterwell.jtwitter.URLConnectionHttpClient.getPage(URLConnectionHttpClient.java:240)
Thanks for response and excuse me, my basic english XD
The client is trying to authenticate for the getRetweeters() call, and you're using an un-authenticated Twitter object -- or perhaps one with an invalid OAuth token.
Actually, it is now not necessary to authenticate for this call. If you download the latest version of JTwitter, it will allow this method with anonymous clients (created using the no-argument Twitter() constructor).
Alternatively, you can use an OAuthSignpostClient() with a valid access token.
精彩评论