Twitter fabric,获取用户名
Twitter fabric, get user's name
使用 twitter 的 android sdk 登录后如何获取用户名和电子邮件?
TwitterAuthClient authClient = new TwitterAuthClient();
authClient.requestEmail(session, new Callback() {
@Override
public void success(Result result) {
Toast.makeText(getApplicationContext(),"Users email : "+result.data.toString,Toast.LENGTH_LONG).show();
}
@Override
public void failure(TwitterException exception) {
// Do something on failure
}
});
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setOAuthConsumerKey(consumerKey);
builder.setOAuthConsumerSecret(SecretKet);
User user;
AccessToken newAcc = new AccessToken(getoken, getokensecret);
Twitter twitter = new TwitterFactory(builder.build())
.getInstance(newAcc);
try {
String mUserName = twitter.getAccountSettings().getScreenName();
user = twitter.showUser(mUserName);
String username = user.getName();
String email= user.getEmail();
String oauth_uid = Integer.toString((int) user.getId());
} catch (TwitterException e) {
Log.v("ERROR", "API_Get_Twitter_Registration_DATA"+e.toString())
e.printStackTrace();
}
使用 twitter 的 android sdk 登录后如何获取用户名和电子邮件?
TwitterAuthClient authClient = new TwitterAuthClient();
authClient.requestEmail(session, new Callback() {
@Override
public void success(Result result) {
Toast.makeText(getApplicationContext(),"Users email : "+result.data.toString,Toast.LENGTH_LONG).show();
}
@Override
public void failure(TwitterException exception) {
// Do something on failure
}
});
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setOAuthConsumerKey(consumerKey);
builder.setOAuthConsumerSecret(SecretKet);
User user;
AccessToken newAcc = new AccessToken(getoken, getokensecret);
Twitter twitter = new TwitterFactory(builder.build())
.getInstance(newAcc);
try {
String mUserName = twitter.getAccountSettings().getScreenName();
user = twitter.showUser(mUserName);
String username = user.getName();
String email= user.getEmail();
String oauth_uid = Integer.toString((int) user.getId());
} catch (TwitterException e) {
Log.v("ERROR", "API_Get_Twitter_Registration_DATA"+e.toString())
e.printStackTrace();
}