verifyCredentials上的Twitter4J例外

时间:2010-08-31 20:53:35

标签: android twitter twitter4j

我正在创建一个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()在这里不起作用,因为它是匿名用户)

是否有人遇到此问题或类似问题?

提前致谢!

1 个答案:

答案 0 :(得分:2)

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