get() public method

GET wrappwer for oAuthRequest.
public get ( $url, $parameters = [] ) : mixed
return mixed
 public function get_fp($p = '')
 {
     //	$foo = $p->friends_timeline();
     $shop_oper = $this->SynchroOperator->find('first', array('conditions' => array('SynchroOperator.status' => 1)));
     $app_key = $shop_oper['SynchroOperator']['app_key'];
     $app_secret = $shop_oper['SynchroOperator']['app_secret'];
     $access_token = $shop_oper['SynchroOperator']['access_token'];
     $SaeTOAuthV2 = new SaeTOAuthV2($app_key, $app_secret, $access_token);
     $url = 'statuses/friends_timeline';
     $usparm['count'] = 50;
     $usparm['page'] = 1;
     $foo = $SaeTOAuthV2->get($url, $usparm);
     if (empty($foo) || isset($foo['error_code'])) {
         return false;
     }
     $friends_gp = array();
     if (isset($foo['statuses'])) {
         foreach ($foo['statuses'] as $k => $v) {
             $friends_gp[] = $v['user']['name'];
         }
     }
     return $friends_gp;
 }
Ejemplo n.º 2
0
// Callback from Sina.
if (isset($_REQUEST['code'])) {
    // 已经从Sina 获取的access token, 我们就从session 获取
    if (isset($_SESSION["token"])) {
        $token = json_decode($_SESSION["token"], TRUE);
        $tmpUser = json_decode($_SESSION["yii_sina_tmpuser"], TRUE);
    } else {
        $keys = array();
        $keys['code'] = $_REQUEST['code'];
        $keys['redirect_uri'] = WB_CALLBACK_URL;
        try {
            $token = $o->getAccessToken('code', $keys);
            $_SESSION["token"] = json_encode($token);
            //POST token to Yii framework
            $token["r"] = "user/sinacallback";
            $ret = $o->get("http://" . $callback_parse["host"], $token);
            if (!$ret["error"]) {
                ob_clean();
                $tmpUser = $ret["data"];
                $_SESSION["yii_sina_tmpuser"] = json_encode($tmpUser);
            } else {
                // Error happend, todo
                $tmpUser = NULL;
                $error = $ret["error"]["message"];
            }
        } catch (OAuthException $e) {
            // Error
            $error = $e->getMessage();
        }
    }
}