问题描述
我使用的是 Twitter4j 3.0.3 版.
I am using Twitter4j version 3.0.3.
我正在尝试提取关注者 ID 并使用 OAuth.我已经使用 Twitter4j 多年了,对这个框架比较有经验.
I am trying to pull follower id and using OAuth. I have been using Twitter4j for years and am relatively experienced with the framework.
然而,发生了一些奇怪的事情:我的程序将运行良好,然后间歇性地抛出以下堆栈跟踪:
However something strange is happening: My program will run fine and then intermittently throw the following stack trace:
Exception in thread "main" 401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the system clock is in sync.
{"request":"\/1.1\/followers\/ids.json?user_id=20801287&cursor=-1&include_entities=1&include_rts=1","error":"Not authorized"}
Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=92c30ec6 or
http://www.google.co.jp/search?q=19400604
TwitterException{exceptionCode=[92c30ec6-19400604], statusCode=401, message=null, code=-1, retryAfter=-1, rateLimitStatus=RateLimitStatusJSONImpl{remaining=6, limit=15, resetTimeInSeconds=1362898120, secondsUntilReset=890}, version=3.0.3}
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:177)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61)
at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:89)
at twitter4j.TwitterImpl.get(TwitterImpl.java:1817)
at twitter4j.TwitterImpl.getFollowersIDs(TwitterImpl.java:400)
它在下面一行抛出上面的内容:
It throws the above at the following line:
IDs ids= twitter.getFollowersIDs(id,cursor);
上面的行执行得很好,然后没有警告就失败了.
The above line executes just fine and then without warning fails.
注意:我正在检查速率限制,最后一次遇到此问题时,以下行提取的速率限制 JSON 对象是(如下):
Note: I am checking rate limits and the last time I encountered this the rate limit JSON object pulled by the following line was (below):
RateLimitStatus rls=twitter.getRateLimitStatus().get("/followers/ids")
RateLimitStatusJSONImpl{remaining=7, limit=15, resetTimeInSeconds=1362898120, secondsUntilReset=890}
我认为这可能是 Twitter 的间歇性问题,但现在已经持续了几天.
I thought this might have been an intermittent thing with Twitter, but it has been going on for a few days now.
我已经在各种机器上尝试过,但遇到完全相同的问题.
I've tried it from various machines but get exactly the same problem.
呼叫以这种方式失败,大约 20 次呼叫中就有一次失败.
The call fails in this manner, once in approximately 20 calls.
我也在 SE 上看过类似的问题:
I have also read the similar questions on SE:
Twitter4j 401 身份验证 -- 但是,这是 OAuth 不起作用的情况-- 在我的情况下,它似乎工作正常,直到它不正常为止.
Twitter4j 401 Authentication -- However, this is a case where OAuth was not working -- in my case it seems to be working fine until of course when it doesn't.
twitter4j:甚至出现凭据错误虽然我已经设置了它们? - 这里与我的情况相似的不多.
twitter4j: getting credential errors even though i had set them? -- again not much here that is similar to my case.
twitter4j 的 Oauth 问题 -- 建议将该应用注册为我已经完成了一个网络应用程序,我已经填写了回调 url(虽然它什么也没做),但仍然没有运气.
Problem in Oauth with twitter4j -- suggest registering the app as a web-app, which I've done, I've filling in the callback url (though it does nothing), but still no luck.
推荐答案
该异常似乎是由可能是私有的 twitter 个人资料的 id 引起的.
The exception seems to be caused by ids of twitter profiles that may be private.
这篇关于Twitter4j:调用 getFollowersIDs 时出现不一致的身份验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!