2

Is there any SDK of Twitter available through which we can implement Twitter in our application? I want that my application would load on his/her Twitter account and then the tweet should be sent to his/her account, but I cannot find any simple examples.

Something like the Facebook Android SDK is what I'm look for.

Emil Vikström
  • 90,431
  • 16
  • 141
  • 175
  • 1
    You want a Twitter SDK to implement Facebook? :) You could try http://twitter4j.org/ ... its worked well for me. – Reuben Scratton Feb 18 '11 at 09:39
  • hey reuben thank 4 ur reply n i want to implement twitter using twitter sdk bt nt getting its sdk and i hv already tried using twitter4j bt not getting proper output –  Feb 18 '11 at 09:51
  • and 1 more thing it is opening in browser not on our application and i dnt want that –  Feb 18 '11 at 09:53
  • @Jazz: did you know that you can accept answers as best answers by clicking the checkmark next to them? – Heiko Rupp Feb 26 '11 at 21:28
  • possible duplicate of [Integrating Twitter in an Android application](http://stackoverflow.com/questions/5038084/integrating-twitter-in-an-android-application) – Brad Larson Feb 28 '11 at 15:51

4 Answers4

6

You can use twitter4j. This site also contains some usage examples.

Unfortunately with the introduction of oAuth, login is no longer trivial. You have to register your application with Twitter (go to your account, then applications and add the app there). This will give you a consumer key/token pair, that you need for logging in and that you need to keep secret.

I've implemented this in my Android-Client called Zwitscher.

You can have a look at the Login procedure in the LoginActivity (of the v0.65 tag).

Heiko Rupp
  • 30,426
  • 13
  • 82
  • 119
  • hey thanx 4 ur response i had a look on this android-client 'Zwitscher' bt its giving some error. its some class file r missing –  Feb 18 '11 at 09:58
  • Yes. Please see the README at top level. This describes where your consumer key needs to go. – Heiko Rupp Feb 18 '11 at 10:16
0

As @Heiko said, twitter4j is quite good. You should use it.

For an example of how it works, I have created a simple sample app that can be found here.

Check that out, maybe it helps you.

Andrew Whitaker
  • 124,656
  • 32
  • 289
  • 307
Aman Alam
  • 11,231
  • 7
  • 46
  • 81
  • hey Aman thanx 4 giving simple example but Aman as twitter is opening in browser, i want that it should open on our application area onli not on browser –  Feb 18 '11 at 10:49
  • This is not how OAuth is supposed to work. It is designed in a way that Users provide username/password to he service provider (in this case, Twitter) only. so you have to open twitter.com I have created it the way to replicate the experience as on has on the web – Aman Alam Feb 18 '11 at 11:04
  • you have to open the browser for the authentification - after that you can use the API inside your app! – Blitz Feb 18 '11 at 11:04
0

If you just want to post a tweet to twitter, use the Android SEND Intent. That way, the user can choose what he want's to do with the post himself. It's much easier for you as well. No worrying about OAuth etc.

Blitz
  • 5,521
  • 3
  • 35
  • 53
  • hii LordT i hd found one apk for twitter its https://github.com/sugree/twitter-android-sdk and its working also. First it ask 4 login and permission for allowing application. I want that after this the tweet sent to the person's login account –  Feb 18 '11 at 11:14
  • if you use SEND intent action, then Android will present you with various other options too, like email, text message, bluetooth and all. consider a case when a device doesn't have a twitter application, then it won't be in the list of applications handling the SEND action. thus, you need to go for OAuth with twitter and step – Aman Alam Feb 18 '11 at 12:00
  • it's true that there has to be some twitter app installed to use it, which will prob. be true 95% of the time. And yes, it's a bit nicer (from the user perspective) to have in app twitter. But on the other hand, the twitter choosen OAuth Process is rather complicated and cumbersome, also for the user (PIN Auth, hello there). And SEND intent's allow you to post to FB, Orkut, Xing etc as well. So if you just want to post messages, I'd always just use SEND intents - why would you restrict your users if other options are available? – Blitz Feb 18 '11 at 13:47
-1

AFAIK there is no sdk provided for twitter. You can however use XAUTH for twitter. It is fairly easy to implement it.

This post might be able to help you.

xAuth Authentication for Twitter Share in Android?

Community
  • 1
  • 1
Umesh
  • 4,406
  • 2
  • 25
  • 37