/**
  * 获取第三方用户信息
  *
  * @param siteMark
  * @param openId
  * @param accessToken
  * @return
  */
 public static BindSite getBindSite(SiteMark siteMark, String openId, String accessToken) {
   BindSite bs = new BindSite();
   bs.setSiteMark(siteMark);
   bs.setOpenId(openId);
   bs.setAccessToken(accessToken);
   String nickName = null;
   if (SiteMark.QQ.equals(siteMark)) {
     UserInfo ui = new UserInfo(accessToken, openId);
     UserInfoBean uib = null;
     try {
       uib = ui.getUserInfo();
     } catch (QQConnectException e) {
       logger.error(e);
       throw new ServiceException(ErrService.UserS.ACC_108, "QQ_API调用异常", "第三方平台异常,请从新尝试!");
     }
     nickName = uib.getNickname();
   } else if (SiteMark.SINA.equals(siteMark)) {
     Users um = new Users();
     um.client.setToken(accessToken);
     try {
       weibo4j.model.User user = um.showUserById(openId);
       nickName = user.getScreenName();
     } catch (WeiboException e) {
       logger.error(e);
       throw new ServiceException(ErrService.UserS.ACC_108, "SINA_API调用异常", "第三方平台异常,请从新尝试!");
     }
   }
   bs.setNickName(nickName);
   return bs;
 }
Пример #2
0
 @Override
 protected String getNickName(Map<String, Object> oParaMap) {
   AccessToken accessToken = (AccessToken) oParaMap.get("token");
   weibo.setToken(accessToken.getAccessToken());
   try {
     User ur = um.showUserById(accessToken.getUid());
     return ur.getScreenName();
   } catch (WeiboException e) {
     log.error("获取新浪昵称失败", e);
   }
   return null;
 }