views:

144

answers:

1

Hello All,

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!

+2  A: 

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.

Frank
Thanks! I will investigate this option.. Is this something twitter has only just introduced? this was working just yesterday..
rhinds
They had announced they would be doing this a while back, and were actually going to do it some time in July but delayed it for the World Cup. It was quite easy to overlook.
Frank
Thanks again - I have been looking at the OAuth setup; for my android app, I want users to be able to login to Twitter using their credentials and then be able to post updates etc - do you know if this is possible? Im walking through the steps to get it up and running and I have just had to enter a PIN in to allow the app to access my Twitter account, will all users have to do this? do all Twitter clients have to go through this process?
rhinds
Further to the above, having experimented with OAuth I am still getting the same error from twitter.. any ideas?
rhinds
looks like im not the only one with the problem this week... HTC having the same problem - will investigate my oauth solution http://www.engadget.com/2010/09/01/htc-peep-cooked-served-a-lorange-by-twitters-new-authenticati/
rhinds