SaeTClientV2::show_user_by_id PHP Method

show_user_by_id() public method

按用户UID或昵称返回用户资料,同时也将返回用户的最新发布的微博。
对应API:{@link http://open.weibo.com/wiki/2/users/show users/show}
public show_user_by_id ( integer $uid ) : array
$uid integer 用户UID。
return array
    function show_user_by_id($uid)
    {
        $params = array();
        if ($uid !== NULL) {
            $this->id_format($uid);
            $params['uid'] = $uid;
        }
        return $this->oauth->get('users/show', $params);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * 从Callback返回时
  */
 public function callback()
 {
     if (isset($_REQUEST['code'])) {
         $keys = array();
         $keys['code'] = $_REQUEST['code'];
         $keys['redirect_uri'] = WB_CALLBACK_URL;
         try {
             $token = $this->sina->getAccessToken('code', $keys);
         } catch (OAuthException $e) {
         }
     }
     if ($token) {
         $_SESSION['token'] = $token;
         setcookie('weibojs_' . $this->sina->client_id, http_build_query($token));
         $c = new SaeTClientV2(WB_AKEY, WB_SKEY, $token['access_token']);
         $ms = $c->home_timeline();
         // done
         $uid_get = $c->get_uid();
         $uid = $uid_get['uid'];
         $user = $c->show_user_by_id($uid);
         //根据ID获取用户等基本信息
         $_SESSION['token']['name'] = $user['name'];
         echo "\n\t\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\t\twindow.opener.callback_exec('Sina' , {$uid} , '{$user['name']}',false);\n\t\t\t\t\t\twindow.close();\n\t\t\t\t\t</script>";
     } else {
         echo '授权失败';
     }
 }
All Usage Examples Of SaeTClientV2::show_user_by_id
SaeTClientV2