userLearner
userLearner

Reputation: 145

Twitter Integration in android using twitter application

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.

Upvotes: 1

Views: 314

Answers (1)

Cipriani
Cipriani

Reputation: 1900

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

Upvotes: 2

Related Questions