if(api == null)
{
Common.sendMessage(fromJID,"您尚未绑定账号,请使用-oauth命令绑定");
return;
}
HTTPResponse response;
if(msgarr.length == 1) //-u
{
response = api.account_verify_credentials(fromJID);
}
else if(msgarr.length == 2) //-u id
{
response = api.users_show(fromJID, msgarr[1]);
}
else
{
doHelp(fromJID,"u");
return;
}
if(response.getResponseCode() == 200)
{
UserJSON jsonUser = new UserJSON(new String(response.getContent()));
String message = null;
message = jsonUser.getScreenName() + " (" + jsonUser.getId() + ") 的信息\n"
+ "头像地址: " + jsonUser.getProfileImageUrl()
+ "\n性别: " + jsonUser.getGender()
+ "\n自述: " + jsonUser.getDescription()
+ "\n地址: " + jsonUser.getLocation()
+ "\nTA关注的人数: " + String.valueOf(jsonUser.getFriendsCount())
+ "\n关注TA的人数: " + String.valueOf(jsonUser.getFollowersCount())
+ "\n收藏消息数: " + String.valueOf(jsonUser.getFavouritesCount())
+ "\n已发消息数: " + String.valueOf(jsonUser.getStatusesCount());
if(jsonUser.getIsFollowing())
{
message = message + "\n\n您已经关注了" + jsonUser.getId();
}
else
{
message = message + "\n\n您没有关注" + jsonUser.getId();
}
Common.sendMessage(fromJID,message);
}
else if(response.getResponseCode() == 403)
{
Common.sendMessage(fromJID,"你没有通过这个用户的验证,无法查看TA的信息");
}
else if(response.getResponseCode() == 404)
{
Common.sendMessage(fromJID,"id所指定的用户不存在");
}
else
{
Common.sendMessage(fromJID,Common.getError(new String(response.getContent())));
Common.log.info(Common.getStrJID(fromJID) + "-u: " + new String(response.getContent()));
}
}