0

I'm using Twitter4j in my java app. working fine and able to get the tweets. I'm using the same formats and code in my android app. I kept the auth secret key in properties file inside package folder and also in asset folder. but i'm getting the following error.

11-30 13:35:46.487: W/System.err(737): java.lang.IllegalStateException: Authentication credentials are missing. See http://twitter4j.org/configuration.html for the detail.
11-30 13:35:46.507: W/System.err(737):  at twitter4j.TwitterBaseImpl.ensureAuthorizationEnabled(TwitterBaseImpl.java:205)
11-30 13:35:46.527: W/System.err(737):  at twitter4j.TwitterImpl.getUserTimeline(TwitterImpl.java:219)
11-30 13:35:46.537: W/System.err(737):  at com.example.MyAndApp.FullScreen.GetTweets(FullScreen.java:359)
11-30 13:35:46.548: W/System.err(737):  at com.example.MyAndApp.FullScreen.access$2(FullScreen.java:352)
11-30 13:35:46.560: W/System.err(737):  at com.example.MyAndApp.FullScreen$DisplayImage.onPostExecute(FullScreen.java:346)
11-30 13:35:46.567: W/System.err(737):  at com.example.MyAndApp.FullScreen$DisplayImage.onPostExecute(FullScreen.java:1)
11-30 13:35:46.578: W/System.err(737):  at android.os.AsyncTask.finish(AsyncTask.java:417)
11-30 13:35:46.601: W/System.err(737):  at android.os.AsyncTask.access$300(AsyncTask.java:127)
11-30 13:35:46.607: W/System.err(737):  at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
11-30 13:35:46.619: W/System.err(737):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-30 13:35:46.637: W/System.err(737):  at android.os.Looper.loop(Looper.java:123)
11-30 13:35:46.647: W/System.err(737):  at android.app.ActivityThread.main(ActivityThread.java:3647)
11-30 13:35:46.658: W/System.err(737):  at java.lang.reflect.Method.invokeNative(Native Method)
11-30 13:35:46.667: W/System.err(737):  at java.lang.reflect.Method.invoke(Method.java:507)
11-30 13:35:46.677: W/System.err(737):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-30 13:35:46.697: W/System.err(737):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)  

The following are the codes i'm using in my aysnctask in post execution method.

Twitter twitter = new TwitterFactory().getInstance();
        List<Status> tweets;
        Paging paging = new Paging();
        paging.setCount(1);
        tweets = twitter.getUserTimeline(paging);

        for (Status tweet : tweets) 
        {
            TweetMsg = tweet.getText();
        }  

Do i need to add anything in Manifest file?

Vignesh
  • 2,295
  • 7
  • 33
  • 41
  • authendication credentials is the issue. whether do you have logged in corretcly ? – itsrajesh4uguys Nov 30 '12 at 09:02
  • hi go through http://blog.enbake.com/developing-an-android-twitter-client-using-twitter4j/ this link – itsrajesh4uguys Nov 30 '12 at 09:03
  • you will get all the details regarding how to use twitter 4j example in Android. http://www.android10.org/index.php/articleslibraries/291-twitter-integration-in-your-android-application from above turrial.. – itsrajesh4uguys Nov 30 '12 at 09:05
  • In the first link, for twitter4j, the application should be browser type. But my android application is not a browser and i just need to take the tweets form the twitter account. – Vignesh Nov 30 '12 at 09:14
  • IGP Thanks for ur answer. but already i implemented code using Twitter4j in java app. need to reuse the code in android app. – Vignesh Nov 30 '12 at 12:03
  • Thanks rajesh, from this link i got the answer.... – Vignesh Nov 30 '12 at 12:06

1 Answers1

3

The above link uses REV 1 oauth, which no longer works. I have written a small Eclipse project that authorizes twitter with REV 1.1:

TwitterTime.zip

hexatron
  • 675
  • 6
  • 9
  • Nice example. The only thing I can't figure out is the callback URL step. Would you mind sharing what that is set to on the twitter dev site? – Matt Aug 27 '13 at 05:02
  • Nevermind. Apparently you just need *any* valid url (e.g. Google) to *enable* callbacks, and then the actual URL gets overwritten dynamically by the request. – Matt Aug 27 '13 at 05:13
  • For whatever reason, the project works just fine by itself. But when I paste it into my existing app, the login page callback goes to mobile.twitter.com rather than returning back to the TwitterTime activity – Matt Aug 27 '13 at 15:38
  • So it turns out that it puts the appName in the Callback URL, so if your appName has a space in it, it fails. – Matt Aug 27 '13 at 16:23