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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.