verifyCredentials 上的 Twitter4J 异常

发布于 2024-09-17 11:37:01 字数 3777 浏览 7 评论 0原文

我正在创建一个 Android 应用程序,它使用 Twitter4J 来读取一些用户信息。

这一切都工作正常,但是今天晚上,当我启动应用程序并且用户登录到 Twitter 时,我遇到了一个异常:

    Twitter twitter = new TwitterFactory().getInstance(twitterID,twitterPassword);
    u = twitter.verifyCredentials();

这在 verifyCredentials() 调用上引发了以下异常:

08-31 20:36:59.084: WARN/System.err(454): twitter4j.TwitterException: https://api.twitter.com/1/account/verify_credentials.json
08-31 20:36:59.094: WARN/System.err(454):     at twitter4j.http.HttpClient.request(HttpClient.java:333)
08-31 20:36:59.094: WARN/System.err(454):     at twitter4j.http.HttpClientWrapper.request(HttpClientWrapper.java:66)
08-31 20:36:59.094: WARN/System.err(454):     at twitter4j.http.HttpClientWrapper.get(HttpClientWrapper.java:88)
08-31 20:36:59.094: WARN/System.err(454):     at twitter4j.Twitter.verifyCredentials(Twitter.java:1025)
08-31 20:36:59.104: WARN/System.err(454):     at com.tmm.android.soundbiter.TwitterInterface.<init>(TwitterInterface.java:65)
08-31 20:36:59.104: WARN/System.err(454):     at com.tmm.android.soundbiter.LogOnActivity.initTwitterUser(LogOnActivity.java:138)
08-31 20:36:59.104: WARN/System.err(454):     at com.tmm.android.soundbiter.LogOnActivity.startApplicationActivity(LogOnActivity.java:102)
08-31 20:36:59.104: WARN/System.err(454):     at com.tmm.android.soundbiter.LogOnActivity.onCreate(LogOnActivity.java:47)
08-31 20:36:59.104: WARN/System.err(454):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-31 20:36:59.104: WARN/System.err(454):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
08-31 20:36:59.104: WARN/System.err(454):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
08-31 20:36:59.104: WARN/System.err(454):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
08-31 20:36:59.115: WARN/System.err(454):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
08-31 20:36:59.115: WARN/System.err(454):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-31 20:36:59.115: WARN/System.err(454):     at android.os.Looper.loop(Looper.java:123)
08-31 20:36:59.115: WARN/System.err(454):     at android.app.ActivityThread.main(ActivityThread.java:4363)
08-31 20:36:59.124: WARN/System.err(454):     at java.lang.reflect.Method.invokeNative(Native Method)
08-31 20:36:59.124: WARN/System.err(454):     at java.lang.reflect.Method.invoke(Method.java:521)
08-31 20:36:59.124: WARN/System.err(454):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
08-31 20:36:59.124: WARN/System.err(454):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
08-31 20:36:59.134: WARN/System.err(454):     at dalvik.system.NativeStart.main(Native Method)
08-31 20:36:59.134: WARN/System.err(454): Caused by: java.io.FileNotFoundException: https://api.twitter.com/1/account/verify_credentials.json
08-31 20:36:59.134: WARN/System.err(454):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1061)
08-31 20:36:59.134: WARN/System.err(454):     at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnection.getInputStream(HttpsURLConnection.java:252)
08-31 20:36:59.134: WARN/System.err(454):     at twitter4j.http.HttpResponse.<init>(HttpResponse.java:83)
08-31 20:36:59.134: WARN/System.err(454):     at twitter4j.http.HttpClient.request(HttpClient.java:288)
08-31 20:36:59.134: WARN/System.err(454):     ... 20 more

正如我提到的,这已经好几周没有改变了,但是我还注意到,如果我匿名实例化我的 Twitter 对象(不传递用户名和密码),那么它仍然允许我从 twitter 检索信息/用户/状态(显然 verifyCredentials() 在这里不起作用因为它是匿名用户)

有没有人遇到过这个问题或类似问题?

提前致谢!

I am creating an Android app that uses Twitter4J to read some user info.

This was all working fine, but this evening when I start the app and the user logs on to Twitter I get an exception:

    Twitter twitter = new TwitterFactory().getInstance(twitterID,twitterPassword);
    u = twitter.verifyCredentials();

This throws the following exception on the verifyCredentials() call:

08-31 20:36:59.084: WARN/System.err(454): twitter4j.TwitterException: https://api.twitter.com/1/account/verify_credentials.json
08-31 20:36:59.094: WARN/System.err(454):     at twitter4j.http.HttpClient.request(HttpClient.java:333)
08-31 20:36:59.094: WARN/System.err(454):     at twitter4j.http.HttpClientWrapper.request(HttpClientWrapper.java:66)
08-31 20:36:59.094: WARN/System.err(454):     at twitter4j.http.HttpClientWrapper.get(HttpClientWrapper.java:88)
08-31 20:36:59.094: WARN/System.err(454):     at twitter4j.Twitter.verifyCredentials(Twitter.java:1025)
08-31 20:36:59.104: WARN/System.err(454):     at com.tmm.android.soundbiter.TwitterInterface.<init>(TwitterInterface.java:65)
08-31 20:36:59.104: WARN/System.err(454):     at com.tmm.android.soundbiter.LogOnActivity.initTwitterUser(LogOnActivity.java:138)
08-31 20:36:59.104: WARN/System.err(454):     at com.tmm.android.soundbiter.LogOnActivity.startApplicationActivity(LogOnActivity.java:102)
08-31 20:36:59.104: WARN/System.err(454):     at com.tmm.android.soundbiter.LogOnActivity.onCreate(LogOnActivity.java:47)
08-31 20:36:59.104: WARN/System.err(454):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-31 20:36:59.104: WARN/System.err(454):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
08-31 20:36:59.104: WARN/System.err(454):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
08-31 20:36:59.104: WARN/System.err(454):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
08-31 20:36:59.115: WARN/System.err(454):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
08-31 20:36:59.115: WARN/System.err(454):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-31 20:36:59.115: WARN/System.err(454):     at android.os.Looper.loop(Looper.java:123)
08-31 20:36:59.115: WARN/System.err(454):     at android.app.ActivityThread.main(ActivityThread.java:4363)
08-31 20:36:59.124: WARN/System.err(454):     at java.lang.reflect.Method.invokeNative(Native Method)
08-31 20:36:59.124: WARN/System.err(454):     at java.lang.reflect.Method.invoke(Method.java:521)
08-31 20:36:59.124: WARN/System.err(454):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
08-31 20:36:59.124: WARN/System.err(454):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
08-31 20:36:59.134: WARN/System.err(454):     at dalvik.system.NativeStart.main(Native Method)
08-31 20:36:59.134: WARN/System.err(454): Caused by: java.io.FileNotFoundException: https://api.twitter.com/1/account/verify_credentials.json
08-31 20:36:59.134: WARN/System.err(454):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1061)
08-31 20:36:59.134: WARN/System.err(454):     at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnection.getInputStream(HttpsURLConnection.java:252)
08-31 20:36:59.134: WARN/System.err(454):     at twitter4j.http.HttpResponse.<init>(HttpResponse.java:83)
08-31 20:36:59.134: WARN/System.err(454):     at twitter4j.http.HttpClient.request(HttpClient.java:288)
08-31 20:36:59.134: WARN/System.err(454):     ... 20 more

As I mentioned, this has not changed for weeks, but has just suddenly stopped working.. I have also noticed that if I instantiate my Twitter object annonymously (dont pass username and password) then it still allows me to retrieve information/users/statuses from twitter (obviously verifyCredentials() does not work here though as it is an anonymous user)

Has anyone experienced this issue or similar?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷鸟归林 2024-09-24 11:37:01

Twitter API 不再支持基本身份验证,您必须更改应用程序以使用 OAuth,http://dev。 twitter.com/pages/auth_overview ,它也内置于 Twitter4J 中。

The Twitter API no longer supports Basic Authentication, you must change your application to use OAuth, http://dev.twitter.com/pages/auth_overview , which is built into Twitter4J also.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文