arun-r 8 twitter android twitter-fabric
我在登录后使用Fabric插件和Android工作室我得到了会话,用户名和用户ID.还有电子邮件地址.但是找不到任何获取用户个人资料照片的选项.
/
/inti twitter client
loginButton = (TwitterLoginButton) findViewById(R.id.twitter_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
System.out.println("twitter success"+result.data.getUserId()+result.data.getUserName());
gettwitteremail();
}
@Override
public void failure(TwitterException exception) {
// Do something on failure
}
});
private void gettwitteremail(){
TwitterSession session =
Twitter.getSessionManager().getActiveSession();
TwitterAuthToken authToken = session.getAuthToken();
String token = authToken.token;
String secret = authToken.secret;
TwitterAuthClient authClient = new TwitterAuthClient();
authClient.requestEmail(session, new Callback() {
@Override
public void success(Result result) {
// Do something with the result, which provides
// the email address
System.out.println("twitter sucess"+result.data);
}
@Override
public void failure(TwitterException exception) {
// Do something on failure
System.out.println("twitter sucess"+exception.getMessage());
exception.printStackTrace();
}
});
固定
通过使用以下代码修复
TwitterSession session =
Twitter.getSessionManager().getActiveSession();
TwitterAuthToken authToken = session.getAuthToken();
String token = authToken.token;
String secret = authToken.secret;
TwitterApiClient twitterApiClient = Twitter.getApiClient();
StatusesService twapiclient = twitterApiClient.getStatusesService();
twapiclient.userTimeline(twitteruserid,null,null,null,null,null,null,null,null,new Callback<List<Tweet>>() {
@Override
public void success(Result<List<Tweet>> listResult) {
System.out.println("listResult"+listResult.data.size());
System.out.println("listResult"+listResult.data.get(0).user);
System.out.println("listResult"+listResult.data.get(0).user.profileImageUrl);
userInfo.imageurl = listResult.data.get(0).user.profileImageUrl;
}
@Override
public void failure(TwitterException e) {
}
});