app_key; $pare['redirect_uri'] = $callblock; $pare['response_type'] = 'code'; //$pare['state'] = $callblock; $pare['scope'] = $this->scope; $pare['display'] = $this->display; setcookie('___OATH2_CALLBLOCK__' , $callblock , time()+3600 , '/'); $p = array_merge($pare , $this->post_login); $p = $this->unset_null($p); return $this->authorizeURL .'?'. http_build_query($p); } function getAccessToken() { if(method_exists($this , 'gettoken')) { $this->token = $this->gettoken(); return $this->token; } $pare = array(); $pare['client_id'] = $this->app_key; $pare['client_secret'] = $this->app_secret; $pare['grant_type'] = 'authorization_code'; $pare['code'] = $_REQUEST['code']; $pare['redirect_uri'] = $_COOKIE['___OATH2_CALLBLOCK__']; //print_r($_COOKIE); setcookie('___OATH2_CALLBLOCK__' , '' , time()-3600 , '/'); $p = array_merge( $pare , $this->post_token); $p = $this->unset_null($p); $result = $this->http($this->tokenURL , $this->meth , $p); if(method_exists($this , 'getGraph')) { $token = $this->getGraph($result); } else { $token = json_decode($result , true); } $this->token = $token; return $token; } function setAccessToken( $token ){$this->token = $token; return true;} function getMessage() { $pare = array(); $pare['client_id'] = $this->app_key; $pare['client_secret'] = $this->app_secret; $pare['access_token'] = $this->token['access_token']; if(!empty($this->token['refresh_token'])) { $pare['refresh_token'] = $this->token['refresh_token']; } $p = array_merge( $pare , $this->token , $this->post_msg); $p = $this->unset_null($p); if(method_exists($this , 'sign')) { $this->sign( $p ); } $result = $this->http($this->userURL , $this->meth , $p); if(method_exists($this , 'is_error')) { $info = $this->is_error($result); } else { $info = json_decode($result , true); } if( method_exists($this , 'message') ) { $info = $this->message($info); } return $info; } function unset_null( $pare ){$arr = $pare;foreach($arr as $key => $val){if(empty($val)){unset($arr[$key]);}}return $arr;} } } ?>