예제 #1
0
 public function getUserInfo($access_token)
 {
     //Get the correct Profile Endpoint URL based off the country/region provided in the _config['region']
     $this->_profileEndpointUrl();
     if (empty($access_token)) {
         throw new InvalidArgumentException('Access Token is a required parameter and is not set');
     }
     //to make sure double encoding doesn't occur decode first and encode again.
     $access_token = urldecode($access_token);
     $url = $this->_profileEndpoint . '/auth/o2/tokeninfo?access_token=' . urlencode($access_token);
     $httpCurlRequest = new HttpCurl();
     $httpCurlRequest->_httpGet($url);
     $response = $httpCurlRequest->getResponse();
     $data = json_decode($response);
     if ($data->aud != $this->_config['client_id']) {
         // the access token does not belong to us
         throw new Exception('The Access token entered is incorrect');
     }
     // exchange the access token for user profile
     $url = $this->_profileEndpoint . '/user/profile';
     $httpCurlRequest = new HttpCurl();
     $httpCurlRequest->setAccessToken($access_token);
     $httpCurlRequest->setHttpHeader(true);
     $httpCurlRequest->_httpGet($url);
     $response = $httpCurlRequest->getResponse();
     $userInfo = json_decode($response, true);
     return $userInfo;
 }
 private function _getCertificate($certificatePath)
 {
     $httpCurlRequest = new HttpCurl($this->_ipnConfig);
     $httpCurlRequest->_httpGet($certificatePath);
     $response = $httpCurlRequest->getResponse();
     return $response;
 }