config = Config::getInstance()->get('passport'); //$this->objMemcached = new Memcached(); //$this->refer = 'passportRefer'; } public function doGet() { $refer = Request::g ( 'referer' ); $cas_uid = Request::g ( 'cas_uid' ); $tokenid = Request::g ( 'tokenid' ); $objUserData = new UserInfo(); $userData = $objUserData -> get($cas_uid); //$this->objMemcached->set($this->refer, $refer); $host = $this->config['url']; $param = $this->config['param']; /* if ($param) { foreach ($param as $k => $v) { if ($v == '{passport_uid}') { if (isset($userData['passport_uid']) && $userData['passport_uid']) { $param[$k] = $userData['passport_uid']; } else { $param[$k] = $v = $tokenid; } } if (!$v) { unset($param[$k]); } } } */ $param['authorizedCode'] = 'fulishe'; $param['tokenId'] = $tokenid; //echo $this->config['url'] . "\r\n"; //print_r($param); $param['tokenId'] = preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $param['tokenId']); $data = $this->httpPost($host, $param); $data = json_decode($data, true); /* $data['data'] = array ( 'nickName' => 'rabin', 'avatar' => 'http://echarts.baidu.com/images/logo.png', 'tokenId' => '111111', ); */ if (isset($data['data']) && isset($data['data']['userId']) && $data['data']['userId']) { $refer = urldecode($refer); $refer = str_replace('&', '&', $refer); $param['nickname'] = $data['data']['nickName']; $param['headimgurl'] = $data['data']['avatar']; $param['uid'] = $data['data']['userId']; $refer .= '&' . http_build_query($param); header ( "Location: " . $refer); } else { echo $tokenid . "
"; print_r($data);die; } } private function httpGet($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 500); curl_setopt($curl, CURLOPT_URL, $url); $res = curl_exec($curl); curl_close($curl); return $res; } private function httpPost($url, $param) { $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 500); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $param); $res = curl_exec($curl); curl_close($curl); return $res; } }