I used Twitter API to do a simple login with twitter to get a few of the user's data. In the javaDocs, there's a User model which contains all the info for a user. I want access to these data. I just can't figure out how to actually get them.!?
My code:
public class MainActivity extends AppCompatActivity {
public TwitterLoginButton loginButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Twitter.initialize(this);
TwitterConfig config = new TwitterConfig.Builder(this)
.logger(new DefaultLogger(Log.DEBUG))
.twitterAuthConfig(
new TwitterAuthConfig(getString(R.string.com_twitter_sdk_android_CONSUMER_KEY),
getString(R.string.com_twitter_sdk_android_CONSUMER_SECRET)))
.debug(true)
.build();
Twitter.initialize(config);
setContentView(R.layout.activity_main);
loginButton = (TwitterLoginButton) findViewById(R.id.login_button);
loginButton.setCallback(new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
// Do something with result, which provides a TwitterSession for making API calls
Log.i("Twitter response ", result.data.getUserName());
}
@Override
public void failure(TwitterException exception) {
// Do something on failure
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Pass the activity result to the login button.
loginButton.onActivityResult(requestCode, resultCode, data);
for (String key : data.getExtras().keySet()) {
Log.d("Bundle Debug", key + " = \"" + data.getExtras().get(key) + "\"");
}
}
The logcat
// logcat: Bundle Debug log
user_id = "519****"
screen_name = "Alaa****"
tk = "519644856************************"
ts = "s0RkdolPk************************"