I am trying to integrate twitter in my application. I want to authenticate user using twitter application if install in device and its not present open browser, just same as facebook SDK is doing.
I want to get user's access token for posting tweet, get follower list.
Currently i am using twitter4j library.
Any suggestion how can i achieve this.
-
fallow thisMrDumb– MrDumb2014年11月04日 11:36:56 +00:00Commented Nov 4, 2014 at 11:36
-
what you want to achieve.. means share (tweet) to your account?virendrao– virendrao2014年11月04日 11:37:25 +00:00Commented Nov 4, 2014 at 11:37
-
Basically i need user's access tokenuserLearner– userLearner2014年11月04日 11:41:36 +00:00Commented Nov 4, 2014 at 11:41
1 Answer 1
Twitter just launched an official SDK that with only a few lines of code you have Sign in with Twitter working and with all alternate authentication flows implemented (having Twitter app installed, not installed, user cancelation, etc)
Check: http://t.co/fabric
Example:
private void setUpTwitterButton() {
twitterButton = (TwitterLoginButton) findViewById(R.id.twitter_button);
twitterButton.setCallback(new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
// TODO: success flow
}
@Override
public void failure(TwitterException exception) {
// TODO: failure flow
}
});
}
The access token will be in the result object of success method above.
The Android docs are here: http://t.co/fabric-android
If you want to see a app sample with this SDK: https://github.com/twitterdev/cannonball-android