summaryrefslogtreecommitdiff
path: root/hauth
diff options
context:
space:
mode:
authorspiderr <spiderr@bitweaver.org>2019-03-27 14:33:25 -0400
committerspiderr <spiderr@bitweaver.org>2019-03-27 14:33:25 -0400
commitcab532c5123e2c7c476d35770bfb351e6056e6e3 (patch)
tree241270b8a8b6101a8d09079a3c1e2ddb21984429 /hauth
parent56c23efba2a5f8689e9c5c1f26483fca1ee295be (diff)
downloadusers-cab532c5123e2c7c476d35770bfb351e6056e6e3.tar.gz
users-cab532c5123e2c7c476d35770bfb351e6056e6e3.tar.bz2
users-cab532c5123e2c7c476d35770bfb351e6056e6e3.zip
upgrade HybridAuth from 2.9.5 to 2.14.0
Diffstat (limited to 'hauth')
-rw-r--r--hauth/Hybrid/Auth.php11
-rw-r--r--hauth/Hybrid/Provider_Model.php29
-rw-r--r--hauth/Hybrid/Providers/Facebook.php67
-rw-r--r--hauth/Hybrid/Providers/Google.php150
-rw-r--r--hauth/Hybrid/Providers/LinkedIn.php20
-rw-r--r--hauth/Hybrid/Providers/Live.php14
-rw-r--r--hauth/Hybrid/Providers/Paypal.php299
-rw-r--r--hauth/Hybrid/Providers/PaypalOpenID.php184
-rw-r--r--hauth/Hybrid/Providers/Yahoo.php2
-rw-r--r--hauth/Hybrid/thirdparty/Paypal/PaypalOAuth2Client.php142
10 files changed, 469 insertions, 449 deletions
diff --git a/hauth/Hybrid/Auth.php b/hauth/Hybrid/Auth.php
index 1f9f1e6..aa0a610 100644
--- a/hauth/Hybrid/Auth.php
+++ b/hauth/Hybrid/Auth.php
@@ -3,7 +3,7 @@
/**
* HybridAuth
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
- * (c) 2009-2015, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
+ * (c) 2009-2017, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
/**
@@ -15,7 +15,7 @@
*/
class Hybrid_Auth {
- public static $version = "2.9.5";
+ public static $version = "2.14.0";
/**
* Configuration array
@@ -402,7 +402,12 @@ class Hybrid_Auth {
$url = $protocol . $_SERVER['HTTP_HOST'];
if ($request_uri) {
- $url .= $_SERVER['REQUEST_URI'];
+ // If $_SERVER['REQUEST_URI'] is already a FQDN, use it
+ if (stripos($_SERVER['REQUEST_URI'], $url) === 0) {
+ $url = $_SERVER['REQUEST_URI'];
+ } else {
+ $url .= $_SERVER['REQUEST_URI'];
+ }
} else {
$url .= $_SERVER['PHP_SELF'];
}
diff --git a/hauth/Hybrid/Provider_Model.php b/hauth/Hybrid/Provider_Model.php
index 9f5798b..cd72f54 100644
--- a/hauth/Hybrid/Provider_Model.php
+++ b/hauth/Hybrid/Provider_Model.php
@@ -64,8 +64,11 @@ abstract class Hybrid_Provider_Model {
*/
public $compressed = false;
- /** @var bool $useSafeUrls Enable this to replace '.' with '_' characters in the callback urls */
- public $useSafeUrls = false;
+ /**
+ * Enable this to replace '.' with '_' characters in the callback urls
+ * @var bool $useSafeUrls
+ */
+ public $useSafeUrls = false;
/**
* Common providers adapter constructor
@@ -130,6 +133,28 @@ abstract class Hybrid_Provider_Model {
*/
abstract public function loginFinish();
+
+ /**
+ * Require autoload.php for 3rd party libraries
+ */
+ protected function autoLoaderInit() {
+ // Check if there is SDK in thirdparty/[providerId].
+ $filename = Hybrid_Auth::$config["path_libraries"] . "{$this->providerId}/autoload.php";
+ if (file_exists($filename)) {
+ require_once $filename;
+ }
+ else {
+ // If Composer install was executed, try to find autoload.php.
+ $vendorDir = dirname(Hybrid_Auth::$config['path_base']);
+ do {
+ if (file_exists($vendorDir . "/vendor/autoload.php")) {
+ require_once $vendorDir . "/vendor/autoload.php";
+ break;
+ }
+ } while (($vendorDir = dirname($vendorDir)) !== '/');
+ }
+ }
+
/**
* Generic logout, just erase current provider adapter stored data to let Hybrid_Auth all forget about it
* @return bool
diff --git a/hauth/Hybrid/Providers/Facebook.php b/hauth/Hybrid/Providers/Facebook.php
index 00cf937..ab48370 100644
--- a/hauth/Hybrid/Providers/Facebook.php
+++ b/hauth/Hybrid/Providers/Facebook.php
@@ -23,7 +23,7 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
* @link https://developers.facebook.com/docs/facebook-login/permissions
* @var array $scope
*/
- public $scope = ['email', 'user_about_me', 'user_birthday', 'user_hometown', 'user_location', 'user_website', 'publish_actions', 'read_custom_friendlists'];
+ public $scope = array('email', 'public_profile');
/**
* Provider API client
@@ -53,25 +53,13 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
$trustForwarded = isset($this->config['trustForwarded']) ? (bool)$this->config['trustForwarded'] : false;
- // Check if there is Graph SDK in thirdparty/Facebook.
- if (file_exists(Hybrid_Auth::$config["path_libraries"] . "Facebook/autoload.php")) {
- require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/autoload.php";
- }
- else {
- // If Composer install was executed, try to find autoload.php.
- $vendorDir = dirname(Hybrid_Auth::$config['path_base']);
- do {
- if (file_exists($vendorDir . "/vendor/autoload.php")) {
- require_once $vendorDir . "/vendor/autoload.php";
- break;
- }
- } while (($vendorDir = dirname($vendorDir)) !== '/');
- }
+ // Include 3rd-party SDK.
+ $this->autoLoaderInit();
$this->api = new FacebookSDK([
'app_id' => $this->config["keys"]["id"],
'app_secret' => $this->config["keys"]["secret"],
- 'default_graph_version' => 'v2.8',
+ 'default_graph_version' => !empty($this->config['default_graph_version']) ? $this->config['default_graph_version'] : 'v2.12',
'trustForwarded' => $trustForwarded,
]);
}
@@ -97,6 +85,9 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
function loginFinish() {
$helper = $this->api->getRedirectLoginHelper();
+ if (isset($_GET['state'])) {
+ $helper->getPersistentDataHandler()->set('state', $_GET['state']);
+ }
try {
$accessToken = $helper->getAccessToken($this->params['login_done']);
} catch (Facebook\Exceptions\FacebookResponseException $e) {
@@ -187,8 +178,9 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
* {@inheridoc}
*/
function getUserPages($writableonly = false) {
- if (( isset($this->config['scope']) && strpos($this->config['scope'], 'manage_pages') === false ) || (!isset($this->config['scope']) && strpos($this->scope, 'manage_pages') === false ))
- throw new Exception("User status requires manage_page permission!");
+ if (!in_array('manage_pages', $this->scope)) {
+ throw new Exception("Get user pages requires manage_page permission!");
+ }
try {
$pages = $this->api->get("/me/accounts", $this->token('access_token'));
@@ -220,7 +212,7 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
*/
function getUserProfile() {
try {
- $fields = [
+ $fields = array(
'id',
'name',
'first_name',
@@ -234,7 +226,7 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
'hometown',
'location',
'birthday'
- ];
+ );
$response = $this->api->get('/me?fields=' . implode(',', $fields), $this->token('access_token'));
$data = $response->getDecodedBody();
} catch (FacebookSDKException $e) {
@@ -246,7 +238,7 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
$this->user->profile->displayName = (array_key_exists('name', $data)) ? $data['name'] : "";
$this->user->profile->firstName = (array_key_exists('first_name', $data)) ? $data['first_name'] : "";
$this->user->profile->lastName = (array_key_exists('last_name', $data)) ? $data['last_name'] : "";
- $this->user->profile->photoURL = !empty($this->user->profile->identifier) ? "https://graph.facebook.com/" . $this->user->profile->identifier . "/picture?width=150&height=150" : '';
+ $this->user->profile->photoURL = $this->getUserPhoto($this->user->profile->identifier);
$this->user->profile->profileURL = (array_key_exists('link', $data)) ? $data['link'] : "";
$this->user->profile->webSiteURL = (array_key_exists('website', $data)) ? $data['website'] : "";
$this->user->profile->gender = (array_key_exists('gender', $data)) ? $data['gender'] : "";
@@ -287,8 +279,12 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
* {@inheritdoc}
*/
function getUserContacts() {
+ if (!in_array('user_friends', $this->scope)) {
+ throw new Exception("Get user contacts requires user_friends permission!");
+ }
+
$apiCall = '?fields=link,name';
- $returnedContacts = [];
+ $returnedContacts = array();
$pagedList = true;
while ($pagedList) {
@@ -312,15 +308,14 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
$returnedContacts = array_merge($returnedContacts, $response['data']);
}
- $contacts = [];
-
+ $contacts = array();
foreach ($returnedContacts as $item) {
$uc = new Hybrid_User_Contact();
$uc->identifier = (array_key_exists("id", $item)) ? $item["id"] : "";
$uc->displayName = (array_key_exists("name", $item)) ? $item["name"] : "";
$uc->profileURL = (array_key_exists("link", $item)) ? $item["link"] : "https://www.facebook.com/profile.php?id=" . $uc->identifier;
- $uc->photoURL = "https://graph.facebook.com/" . $uc->identifier . "/picture?width=150&height=150";
+ $uc->photoURL = $this->getUserPhoto($uc->identifier);
$contacts[] = $uc;
}
@@ -349,11 +344,10 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
}
if (!$response || !count($response['data'])) {
- return [];
+ return array();
}
- $activities = [];
-
+ $activities = array();
foreach ($response['data'] as $item) {
$ua = new Hybrid_User_Activity();
@@ -381,7 +375,7 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
$ua->user->identifier = (array_key_exists("id", $item["from"])) ? $item["from"]["id"] : "";
$ua->user->displayName = (array_key_exists("name", $item["from"])) ? $item["from"]["name"] : "";
$ua->user->profileURL = "https://www.facebook.com/profile.php?id=" . $ua->user->identifier;
- $ua->user->photoURL = "https://graph.facebook.com/" . $ua->user->identifier . "/picture?type=square";
+ $ua->user->photoURL = $this->getUserPhoto($ua->user->identifier);
$activities[] = $ua;
}
@@ -390,4 +384,19 @@ class Hybrid_Providers_Facebook extends Hybrid_Provider_Model {
return $activities;
}
+ /**
+ * Returns a photo URL for give user.
+ *
+ * @param string $id
+ * The User ID.
+ *
+ * @return string
+ * A photo URL.
+ */
+ function getUserPhoto($id) {
+ $photo_size = isset($this->config['photo_size']) ? $this->config['photo_size'] : 150;
+
+ return "https://graph.facebook.com/{$id}/picture?width={$photo_size}&height={$photo_size}";
+ }
+
}
diff --git a/hauth/Hybrid/Providers/Google.php b/hauth/Hybrid/Providers/Google.php
index d71cc0a..bcafa94 100644
--- a/hauth/Hybrid/Providers/Google.php
+++ b/hauth/Hybrid/Providers/Google.php
@@ -19,7 +19,7 @@ class Hybrid_Providers_Google extends Hybrid_Provider_Model_OAuth2 {
* default permissions
* {@inheritdoc}
*/
- public $scope = "https://www.googleapis.com/auth/plus.login"; // https://www.googleapis.com/auth/plus.profile.emails.read https://www.google.com/m8/feeds/";
+ public $scope = "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.google.com/m8/feeds/";
/**
* {@inheritdoc}
@@ -72,122 +72,21 @@ class Hybrid_Providers_Google extends Hybrid_Provider_Model_OAuth2 {
// refresh tokens if needed
$this->refreshToken();
- // ask google api for user infos
- if (strpos($this->scope, '/auth/plus.profile.emails.read') !== false) {
- $verified = $this->api->api("https://www.googleapis.com/plus/v1/people/me");
-
- if (!isset($verified->id) || isset($verified->error))
- $verified = new stdClass();
- } else {
- $verified = $this->api->api("https://www.googleapis.com/plus/v1/people/me/openIdConnect");
-
- if (!isset($verified->sub) || isset($verified->error))
- $verified = new stdClass();
- }
-
- $response = $this->api->api("https://www.googleapis.com/plus/v1/people/me");
- if (!isset($response->id) || isset($response->error)) {
+ $response = $this->api->api("https://www.googleapis.com/oauth2/v3/userinfo");
+ if (!isset($response->sub) || isset($response->error)) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response:" . Hybrid_Logger::dumpData( $response ), 6);
}
- $this->user->profile->identifier = (property_exists($verified, 'id')) ? $verified->id : ((property_exists($response, 'id')) ? $response->id : "");
- $this->user->profile->firstName = (property_exists($response, 'name')) ? $response->name->givenName : "";
- $this->user->profile->lastName = (property_exists($response, 'name')) ? $response->name->familyName : "";
- $this->user->profile->displayName = (property_exists($response, 'displayName')) ? $response->displayName : "";
- $this->user->profile->photoURL = (property_exists($response, 'image')) ? ((property_exists($response->image, 'url')) ? substr($response->image->url, 0, -2) . "200" : '') : '';
- $this->user->profile->profileURL = (property_exists($response, 'url')) ? $response->url : "";
- $this->user->profile->description = (property_exists($response, 'aboutMe')) ? $response->aboutMe : "";
+ $this->user->profile->identifier = (property_exists($response, 'sub')) ? $response->sub : "";
+ $this->user->profile->firstName = (property_exists($response, 'given_name')) ? $response->given_name : "";
+ $this->user->profile->lastName = (property_exists($response, 'family_name')) ? $response->family_name : "";
+ $this->user->profile->displayName = (property_exists($response, 'name')) ? $response->name : "";
+ $this->user->profile->photoURL = (property_exists($response, 'picture')) ? $response->picture : "";
+ $this->user->profile->profileURL = (property_exists($response, 'profile')) ? $response->profile : "";
$this->user->profile->gender = (property_exists($response, 'gender')) ? $response->gender : "";
- $this->user->profile->language = (property_exists($response, 'locale')) ? $response->locale : ((property_exists($verified, 'locale')) ? $verified->locale : "");
- $this->user->profile->email = (property_exists($response, 'email')) ? $response->email : ((property_exists($verified, 'email')) ? $verified->email : "");
- $this->user->profile->emailVerified = (property_exists($verified, 'email')) ? $verified->email : "";
- if (property_exists($response, 'emails')) {
- if (count($response->emails) == 1) {
- $this->user->profile->email = $response->emails[0]->value;
- } else {
- foreach ($response->emails as $email) {
- if ($email->type == 'account') {
- $this->user->profile->email = $email->value;
- break;
- }
- }
- }
- if (property_exists($verified, 'emails')) {
- if (count($verified->emails) == 1) {
- $this->user->profile->emailVerified = $verified->emails[0]->value;
- } else {
- foreach ($verified->emails as $email) {
- if ($email->type == 'account') {
- $this->user->profile->emailVerified = $email->value;
- break;
- }
- }
- }
- }
- }
- $this->user->profile->phone = (property_exists($response, 'phone')) ? $response->phone : "";
- $this->user->profile->country = (property_exists($response, 'country')) ? $response->country : "";
- $this->user->profile->region = (property_exists($response, 'region')) ? $response->region : "";
- $this->user->profile->zip = (property_exists($response, 'zip')) ? $response->zip : "";
- if (property_exists($response, 'placesLived')) {
- $this->user->profile->city = "";
- $this->user->profile->address = "";
- foreach ($response->placesLived as $c) {
- if (property_exists($c, 'primary')) {
- if ($c->primary == true) {
- $this->user->profile->address = $c->value;
- $this->user->profile->city = $c->value;
- break;
- }
- } else {
- if (property_exists($c, 'value')) {
- $this->user->profile->address = $c->value;
- $this->user->profile->city = $c->value;
- }
- }
- }
- }
-
- // google API returns multiple urls, but a "website" only if it is verified
- // see http://support.google.com/plus/answer/1713826?hl=en
- if (property_exists($response, 'urls')) {
- foreach ($response->urls as $u) {
- if (property_exists($u, 'primary') && $u->primary == true)
- $this->user->profile->webSiteURL = $u->value;
- }
- } else {
- $this->user->profile->webSiteURL = '';
- }
- // google API returns age ranges min and/or max as of https://developers.google.com/+/web/api/rest/latest/people#resource
- if (property_exists($response, 'ageRange')) {
- if (property_exists($response->ageRange, 'min') && property_exists($response->ageRange, 'max')) {
- $this->user->profile->age = $response->ageRange->min . ' - ' . $response->ageRange->max;
- } else {
- if (property_exists($response->ageRange, 'min')) {
- $this->user->profile->age = '>= ' . $response->ageRange->min;
- } else {
- if (property_exists($response->ageRange, 'max')) {
- $this->user->profile->age = '<= ' . $response->ageRange->max;
- } else {
- $this->user->profile->age = '';
- }
- }
- }
- } else {
- $this->user->profile->age = '';
- }
- // google API returns birthdays only if a user set 'show in my account'
- if (property_exists($response, 'birthday')) {
- list($birthday_year, $birthday_month, $birthday_day) = explode('-', $response->birthday);
-
- $this->user->profile->birthDay = (int) $birthday_day;
- $this->user->profile->birthMonth = (int) $birthday_month;
- $this->user->profile->birthYear = (int) $birthday_year;
- } else {
- $this->user->profile->birthDay = 0;
- $this->user->profile->birthMonth = 0;
- $this->user->profile->birthYear = 0;
- }
+ $this->user->profile->language = (property_exists($response, 'locale')) ? $response->locale : "";
+ $this->user->profile->email = (property_exists($response, 'email')) ? $response->email : "";
+ $this->user->profile->emailVerified = (property_exists($response, 'email_verified')) ? ($response->email_verified === true || $response->email_verified === 1 ? $response->email : "") : "";
return $this->user->profile;
}
@@ -255,31 +154,6 @@ class Hybrid_Providers_Google extends Hybrid_Provider_Model_OAuth2 {
}
}
- // Google social contacts
- if (strpos($this->scope, '/auth/plus.login') !== false) {
-
- $response = $this->api->api("https://www.googleapis.com/plus/v1/people/me/people/visible?"
- . http_build_query($this->config['contacts_param']));
-
- if (!$response) {
- return array();
- }
-
- foreach ($response->items as $idx => $item) {
- $uc = new Hybrid_User_Contact();
- $uc->email = (property_exists($item, 'email')) ? $item->email : '';
- $uc->displayName = (property_exists($item, 'displayName')) ? $item->displayName : '';
- $uc->identifier = (property_exists($item, 'id')) ? $item->id : '';
-
- $uc->description = (property_exists($item, 'objectType')) ? $item->objectType : '';
- $uc->photoURL = (property_exists($item, 'image')) ? ((property_exists($item->image, 'url')) ? $item->image->url : '') : '';
- $uc->profileURL = (property_exists($item, 'url')) ? $item->url : '';
- $uc->webSiteURL = '';
-
- $contacts[] = $uc;
- }
- }
-
return $contacts;
}
diff --git a/hauth/Hybrid/Providers/LinkedIn.php b/hauth/Hybrid/Providers/LinkedIn.php
index 2a442b2..4631b52 100644
--- a/hauth/Hybrid/Providers/LinkedIn.php
+++ b/hauth/Hybrid/Providers/LinkedIn.php
@@ -35,7 +35,14 @@ class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model_OAuth2 {
if (is_array($this->scope)) {
$this->scope = implode(" ", $this->scope);
}
- parent::loginBegin();
+ if (isset($this->scope)) {
+ $extra_params['scope'] = $this->scope;
+ }
+ if (!isset($this->state)) {
+ $this->state = hash("sha256",(uniqid(rand(), TRUE)));
+ }
+ $extra_params['state'] = $this->state;
+ Hybrid_Auth::redirect($this->api->authorizeUrl($extra_params));
}
/**
@@ -49,7 +56,7 @@ class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model_OAuth2 {
$this->refreshToken();
// https://developer.linkedin.com/docs/fields.
- $fields = isset($this->config["fields"]) ? $this->config["fields"] : [
+ $fields = isset($this->config["fields"]) ? $this->config["fields"] : array(
"id",
"email-address",
"first-name",
@@ -59,7 +66,7 @@ class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model_OAuth2 {
"industry",
"picture-url",
"public-profile-url",
- ];
+ );
$this->setHeaders();
$response = $this->api->get(
@@ -95,6 +102,7 @@ class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model_OAuth2 {
* - content: A collection of fields describing the shared content.
* - comment: A comment by the member to associated with the share.
* - visibility: A collection of visibility information about the share.
+ * @param string $companyId (optional) User company id
*
* @return object
* An object containing:
@@ -103,7 +111,7 @@ class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model_OAuth2 {
* @throws Exception
* @see https://developer.linkedin.com/docs/share-on-linkedin
*/
- function setUserStatus($status) {
+ function setUserStatus($status, $companyId = null) {
// Refresh tokens if needed.
$this->setHeaders("token");
$this->refreshToken();
@@ -115,8 +123,8 @@ class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model_OAuth2 {
}
$this->setHeaders("share");
- $response = $this->api->post(
- "people/~/shares?format=json",
+ $url = $companyId ? "companies/{$companyId}/shares?format=json" : "people/~/shares?format=json";
+ $response = $this->api->post($url,
array(
"body" => $status,
)
diff --git a/hauth/Hybrid/Providers/Live.php b/hauth/Hybrid/Providers/Live.php
index 6081feb..0cc2951 100644
--- a/hauth/Hybrid/Providers/Live.php
+++ b/hauth/Hybrid/Providers/Live.php
@@ -23,7 +23,7 @@ class Hybrid_Providers_Live extends Hybrid_Provider_Model_OAuth2 {
/**
* {@inheritdoc}
*/
- public $scope = "wl.basic wl.contacts_emails wl.emails wl.signin wl.share wl.birthday";
+ public $scope = 'wl.basic wl.contacts_emails wl.emails wl.signin wl.share wl.birthday';
/**
* {@inheritdoc}
@@ -33,16 +33,8 @@ class Hybrid_Providers_Live extends Hybrid_Provider_Model_OAuth2 {
// Provider api end-points
$this->api->api_base_url = 'https://apis.live.net/v5.0/';
- $this->api->authorize_url = 'https://oauth.live.com/authorize';
+ $this->api->authorize_url = 'https://login.live.com/oauth20_authorize.srf';
$this->api->token_url = 'https://login.live.com/oauth20_token.srf';
-
- $this->api->curl_authenticate_method = "GET";
-
- // Override the redirect uri when it's set in the config parameters. This way we prevent
- // redirect uri mismatches when authenticating with Live.com
- if (isset($this->config['redirect_uri']) && !empty($this->config['redirect_uri'])) {
- $this->api->redirect_uri = $this->config['redirect_uri'];
- }
}
/**
@@ -65,7 +57,7 @@ class Hybrid_Providers_Live extends Hybrid_Provider_Model_OAuth2 {
$this->user->profile->profileURL = (property_exists($data, 'link')) ? $data->link : "";
//wl.emails
- $this->user->profile->email = (property_exists($data, 'emails')) ? $data->emails->account : "";
+ $this->user->profile->email = (property_exists($data, 'emails')) ? $data->emails->preferred : "";
$this->user->profile->emailVerified = (property_exists($data, 'emails')) ? $data->emails->account : "";
//wl.birthday
diff --git a/hauth/Hybrid/Providers/Paypal.php b/hauth/Hybrid/Providers/Paypal.php
index 36cc646..be0a64b 100644
--- a/hauth/Hybrid/Providers/Paypal.php
+++ b/hauth/Hybrid/Providers/Paypal.php
@@ -1,146 +1,211 @@
<?php
-/*!
-* HybridAuth
-* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
-* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
-*/
-
-/**
- * PayPal OAuth2 Class
- *
- * @package HybridAuth providers package
- * @author Jan Waś <janek.jan@gmail.com>
- * @version 0.2
- * @license BSD License
- */
/**
- * Hybrid_Providers_Paypal - PayPal provider adapter based on OAuth2 protocol
+ * @file
+ * HybridAuth
+ * http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
+ * (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
*/
-class Hybrid_Providers_Paypal extends Hybrid_Provider_Model_OAuth2
-{
- // default permissions
- public $scope = "profile email address phone https://uri.paypal.com/services/paypalattributes";
- public $sandbox = true;
+use PayPal\Api\OpenIdSession;
+use PayPal\Api\OpenIdTokeninfo;
+use PayPal\Api\OpenIdUserinfo;
+use PayPal\Auth\OAuthTokenCredential;
+use PayPal\Exception\PayPalConnectionException;
+use PayPal\Rest\ApiContext;
- /**
- * IDp wrappers initializer
- */
- function initialize()
- {
- if ( ! $this->config["keys"]["id"] || ! $this->config["keys"]["secret"] ){
- throw new Exception( "Your application id and secret are required in order to connect to {$this->providerId}.", 4 );
- }
+/**
+ * PayPal OAuth Class.
+ *
+ * @package HybridAuth providers package
+ * @version 1.0
+ * @license BSD License
+ */
- // override requested scope
- if( isset( $this->config["scope"] ) && ! empty( $this->config["scope"] ) ){
- $this->scope = $this->config["scope"];
- }
+/**
+ * Hybrid_Providers_Paypal - PayPal provider adapter based on OAuth2 protocol.
+ */
+class Hybrid_Providers_Paypal extends Hybrid_Provider_Model
+{
- // include OAuth2 client and Paypal client
- require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth2Client.php";
- require_once Hybrid_Auth::$config["path_libraries"] . "Paypal/PaypalOAuth2Client.php";
+ /**
+ * The access privileges that you are requesting for
+ * from the user. Pass empty array for all scopes.
+ *
+ * @var array $scope
+ * @see https://developer.paypal.com/docs/integration/direct/identity/attributes
+ */
+ public $scope = array();
- // create a new OAuth2 client instance
- $this->api = new PaypalOAuth2Client( $this->config["keys"]["id"], $this->config["keys"]["secret"], $this->endpoint );
+ /**
+ * The provider api client
+ *
+ * @var ApiContext $api
+ */
+ public $api;
- // If we have an access token, set it
- if( $this->token( "access_token" ) ){
- $this->api->access_token = $this->token( "access_token" );
- $this->api->refresh_token = $this->token( "refresh_token" );
- $this->api->access_token_expires_in = $this->token( "expires_in" );
- $this->api->access_token_expires_at = $this->token( "expires_at" );
- }
+ /**
+ * TRUE if sandbox mode is ON otherwise FALSE
+ *
+ * @var bool $sandbox
+ */
+ public $sandbox = true;
- // Set curl proxy if exist
- if( isset( Hybrid_Auth::$config["proxy"] ) ){
- $this->api->curl_proxy = Hybrid_Auth::$config["proxy"];
- }
+ /**
+ * {@inheritdoc}
+ */
+ function initialize()
+ {
+ if (!$this->config["keys"]["id"] || !$this->config["keys"]["secret"]) {
+ throw new Exception("Your application id and secret are required in order to connect to {$this->providerId}.", 4);
+ }
- // Provider api end-points
- if ($this->sandbox) {
- $this->api->authorize_url = "https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize";
- $this->api->token_url = "https://api.sandbox.paypal.com/v1/oauth2/token";
- $this->api->token_info_url = "https://api.sandbox.paypal.com/v1/identity/openidconnect/tokenservice";
- } else {
- $this->api->authorize_url = "https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize";
- $this->api->token_url = "https://api.paypal.com/v1/oauth2/token";
- $this->api->token_info_url = "https://api.paypal.com/v1/identity/openidconnect/tokenservice";
+ // Set scope from config.
+ if (isset($this->config["scope"])) {
+ $scope = $this->config["scope"];
+ if (is_string($scope)) {
+ $scope = explode(" ", $scope);
+ }
+ $scope = array_map("trim", $scope);
+ $this->scope = $scope;
}
- if (Hybrid_Auth::$config["debug_mode"]) {
- $this->api->curl_log = Hybrid_Auth::$config["debug_file"];
+ // Set sandbox from config.
+ if (isset($this->config["sandbox"]) && is_bool($this->config["sandbox"])) {
+ $this->sandbox = $this->config["sandbox"];
}
- }
- /**
- * begin login step
- */
- /*function loginBegin()
- {
- $parameters = array("scope" => $this->scope, "grant_type" => "client_credentials");
- $optionals = array("scope", "access_type", "redirect_uri", "approval_prompt", "hd");
+ // Include 3rd-party SDK.
+ $this->autoLoaderInit();
- foreach ($optionals as $parameter){
- if( isset( $this->config[$parameter] ) && ! empty( $this->config[$parameter] ) ){
- $parameters[$parameter] = $this->config[$parameter];
- }
- }
+ // Set up ApiContext.
+ $this->api = new ApiContext(
+ new OAuthTokenCredential(
+ $this->config["keys"]["id"],
+ $this->config["keys"]["secret"]
+ )
+ );
- Hybrid_Auth::redirect( $this->api->authorizeUrl( $parameters ) );
- }*/
+ // Set up config.
+ $this->api->setConfig(array(
+ "log.LogEnabled" => Hybrid_Auth::$config["debug_mode"],
+ "log.FileName" => Hybrid_Auth::$config["debug_file"],
+ "log.LogLevel" => "DEBUG",
+ "http.CURLOPT_SSLVERSION" => CURL_SSLVERSION_TLSv1,
+ "mode" => $this->sandbox ? "sandbox" : "live",
+ ));
+ }
- /**
- * load the user profile from the IDp api client
- */
- function getUserProfile()
- {
- // refresh tokens if needed
- $this->refreshToken();
+ /**
+ * {@inheritdoc}
+ */
+ function loginBegin()
+ {
+ $url = OpenIdSession::getAuthorizationUrl(
+ $this->endpoint,
+ $this->scope,
+ null,
+ null,
+ null,
+ $this->api
+ );
+ // Redirect to PayPal.
+ Hybrid_Auth::redirect($url);
+ }
- // ask google api for user infos
- $response = $this->api->api( "https://api".($this->sandbox?'.sandbox' : '').".paypal.com/v1/identity/openidconnect/userinfo/?schema=openid" );
+ /**
+ * {@inheritdoc}
+ */
+ function loginFinish()
+ {
+ if (!isset($_GET["code"])) {
+ throw new Exception("Authentication failed! User has canceled authentication!", 5);
+ }
- if ( ! isset( $response->payer_id ) || isset( $response->message ) ){
- throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
- }
+ $code = $_GET["code"];
+ try {
+ // Obtain Authorization Code from Code, Client ID and Client Secret
+ $accessToken = OpenIdTokeninfo::createFromAuthorizationCode(array("code" => $code), null, null, $this->api);
+ if ($accessToken) {
+ $this->setUserConnected();
- $this->user->profile->identifier = (property_exists($response,'payer_id'))?$response->payer_id:"";
- $this->user->profile->firstName = (property_exists($response,'given_name'))?$response->given_name:"";
- $this->user->profile->lastName = (property_exists($response,'family_name'))?$response->family_name:"";
- $this->user->profile->displayName = (property_exists($response,'name'))?$response->name:"";
- $this->user->profile->photoURL = (property_exists($response,'picture'))?$response->picture:"";
- $this->user->profile->gender = (property_exists($response,'gender'))?$response->gender:"";
- $this->user->profile->email = (property_exists($response,'email'))?$response->email:"";
- $this->user->profile->emailVerified = (property_exists($response,'email_verified'))?$response->email_verified:"";
- $this->user->profile->language = (property_exists($response,'locale'))?$response->locale:"";
- $this->user->profile->phone = (property_exists($response,'phone_number'))?$response->phone_number:"";
- if (property_exists($response,'address')) {
- $address = $response->address;
- $this->user->profile->address = (property_exists($address,'street_address'))?$address->street_address:"";
- $this->user->profile->city = (property_exists($address,'locality'))?$address->locality:"";
- $this->user->profile->zip = (property_exists($address,'postal_code'))?$address->postal_code:"";
- $this->user->profile->country = (property_exists($address,'country'))?$address->country:"";
- $this->user->profile->region = (property_exists($address,'region'))?$address->region:"";
+ // Store tokens.
+ $this->token("id_token", $accessToken->getIdToken());
+ $this->token("access_token", $accessToken->getAccessToken());
+ $this->token("refresh_token", $accessToken->getRefreshToken());
+ }
+ } catch (PayPalConnectionException $e) {
+ throw new Hybrid_Exception($e->getMessage(), $e->getCode(), $e);
}
+ }
- if( property_exists($response,'birthdate') ){
- if (strpos($response->birthdate, '-') === false) {
- if ($response->birthdate !== '0000') {
- $this->user->profile->birthYear = (int) $response->birthdate;
- }
- } else {
- list($birthday_year, $birthday_month, $birthday_day) = explode( '-', $response->birthdate );
+ /**
+ * {@inheritdoc}
+ */
+ function logout()
+ {
+ parent::logout();
+ if ($idToken = $this->token("id_token")) {
+ $url = OpenIdSession::getLogoutUrl(
+ $this->params["hauth_return_to"],
+ $idToken,
+ $this->api
+ );
+ // Redirect to PayPal.
+ Hybrid_Auth::redirect($url);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ function getUserProfile()
+ {
+ try {
+ $params = array("access_token" => $this->token("access_token"));
+ $userInfo = OpenIdUserinfo::getUserinfo($params, $this->api);
+
+ $profile = new Hybrid_User_Profile();
- $this->user->profile->birthDay = (int) $birthday_day;
- $this->user->profile->birthMonth = (int) $birthday_month;
- if ($birthday_year !== '0000') {
- $this->user->profile->birthYear = (int) $birthday_year;
+ $profile->identifier = $userInfo->getUserId();
+ $profile->firstName = $userInfo->getGivenName();
+ $profile->lastName = $userInfo->getFamilyName();
+ $profile->displayName = $userInfo->getName();
+ $profile->photoURL = $userInfo->getPicture();
+ $profile->gender = $userInfo->getGender();
+ $profile->email = $userInfo->getEmail();
+ $profile->emailVerified = $userInfo->getEmailVerified();
+ $profile->language = $userInfo->getLocale();
+ $profile->phone = $userInfo->getPhoneNumber();
+ if ($address = $userInfo->getAddress()) {
+ $profile->address = $address->getStreetAddress();
+ $profile->city = $address->getLocality();
+ $profile->zip = $address->getPostalCode();
+ $profile->country = $address->getCountry();
+ $profile->region = $address->getRegion();
+ }
+
+ if ($birthdate = $userInfo->getBirthday()) {
+ if (strpos($birthdate, "-") === FALSE) {
+ if ($birthdate !== "0000") {
+ $profile->birthYear = (int)$birthdate;
+ }
+ } else {
+ list($birthday_year, $birthday_month, $birthday_day) = explode("-", $birthdate);
+
+ $profile->birthDay = (int) $birthday_day;
+ $profile->birthMonth = (int) $birthday_month;
+ if ($birthday_year !== "0000") {
+ $profile->birthYear = (int) $birthday_year;
+ }
}
}
- }
- return $this->user->profile;
- }
+ $this->user->profile = $profile;
+
+ return $this->user->profile;
+ } catch (Exception $e) {
+ throw new Hybrid_Exception($e->getMessage(), $e->getCode(), $e);
+ }
+ }
}
diff --git a/hauth/Hybrid/Providers/PaypalOpenID.php b/hauth/Hybrid/Providers/PaypalOpenID.php
new file mode 100644
index 0000000..6d4b9eb
--- /dev/null
+++ b/hauth/Hybrid/Providers/PaypalOpenID.php
@@ -0,0 +1,184 @@
+<?php
+/**
+* HybridAuth
+* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
+* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
+*/
+
+/**
+ * Hybrid_Providers_PayPal class
+ */
+class Hybrid_Providers_PaypalOpenID extends Hybrid_Provider_Model_OpenID
+{
+ var $openidIdentifier = "https://www.sandbox.paypal.com/webapps/auth/server";
+
+ /**
+ * begin login step
+ */
+ function loginBegin()
+ {
+ if( empty( $this->openidIdentifier ) ){
+ throw new Exception( "OpenID adapter require the identity provider identifier 'openid_identifier' as an extra parameter.", 4 );
+ }
+
+ $this->api->identity = $this->openidIdentifier;
+ $this->api->returnUrl = $this->endpoint;
+ $this->api->required = ARRAY(
+ /*'namePerson/first' ,
+ 'namePerson/last' ,
+ 'namePerson/friendly' ,
+ 'namePerson' ,
+
+ 'contact/email' ,
+
+ 'birthDate' ,
+ 'birthDate/birthDay' ,
+ 'birthDate/birthMonth' ,
+ 'birthDate/birthYear' ,
+
+ 'person/gender' ,
+ 'pref/language' ,
+
+ 'contact/postalCode/home',
+ 'contact/city/home' ,
+ 'contact/country/home' ,
+
+ 'media/image/default' ,*/
+
+ 'namePerson/prefix',
+ 'namePerson/first',
+ 'namePerson/last',
+ 'namePerson/middle',
+ 'namePerson/suffix',
+ 'namePerson/friendly',
+ 'person/guid',
+ 'birthDate/birthYear',
+ 'birthDate/birthMonth',
+ 'birthDate/birthday',
+ 'gender',
+ 'language/pref',
+ 'contact/phone/default',
+ 'contact/phone/home',
+ 'contact/phone/business',
+ 'contact/phone/cell',
+ 'contact/phone/fax',
+ 'contact/postaladdress/home',
+ 'contact/postaladdressadditional/home',
+ 'contact/city/home',
+ 'contact/state/home',
+ 'contact/country/home',
+ 'contact/postalcode/home',
+ 'contact/postaladdress/business',
+ 'contact/postaladdressadditional/business',
+ 'contact/city/business',
+ 'contact/state/business',
+ 'contact/country/business',
+ 'contact/postalcode/business',
+ /*'contact/IM/default',
+ 'contact/IM/AIM',
+ 'contact/IM/ICQ',
+ 'contact/IM/MSN',
+ 'contact/IM/Yahoo',
+ 'contact/IM/Jabber',
+ 'contact/IM/Skype',
+ 'contact/internet/email',
+ 'contact/web/default',
+ 'contact/web/blog',
+ 'contact/web/Linkedin',
+ 'contact/web/Amazon',
+ 'contact/web/Flickr',
+ 'contact/web/Delicious',*/
+ 'company/name',
+ 'company/title',
+ /*'media/spokenname',
+ 'media/greeting/audio',
+ 'media/greeting/video',
+ 'media/biography',
+ 'media/image',
+ 'media/image/16x16',
+ 'media/image/32x32',
+ 'media/image/48x48',
+ 'media/image/64x64',
+ 'media/image/80x80',
+ 'media/image/128x128',
+ 'media/image/160x120',
+ 'media/image/320x240',
+ 'media/image/640x480',
+ 'media/image/120x160',
+ 'media/image/240x320',
+ 'media/image/480x640',
+ 'media/image/favicon',
+ 'timezone',*/
+ );
+ $this->api->optional = array();ARRAY(
+ 'namePerson/prefix',
+ 'namePerson/first',
+ 'namePerson/last',
+ 'namePerson/middle',
+ 'namePerson/suffix',
+ 'namePerson/friendly',
+ 'person/guid',
+ 'birthDate/birthYear',
+ 'birthDate/birthMonth',
+ 'birthDate/birthday',
+ 'gender',
+ 'language/pref',
+ 'contact/phone/default',
+ 'contact/phone/home',
+ 'contact/phone/business',
+ 'contact/phone/cell',
+ 'contact/phone/fax',
+ 'contact/postaladdress/home',
+ 'contact/postaladdressadditional/home',
+ 'contact/city/home',
+ 'contact/state/home',
+ 'contact/country/home',
+ 'contact/postalcode/home',
+ 'contact/postaladdress/business',
+ 'contact/postaladdressadditional/business',
+ 'contact/city/business',
+ 'contact/state/business',
+ 'contact/country/business',
+ 'contact/postalcode/business',
+ /*'contact/IM/default',
+ 'contact/IM/AIM',
+ 'contact/IM/ICQ',
+ 'contact/IM/MSN',
+ 'contact/IM/Yahoo',
+ 'contact/IM/Jabber',
+ 'contact/IM/Skype',
+ 'contact/internet/email',
+ 'contact/web/default',
+ 'contact/web/blog',
+ 'contact/web/Linkedin',
+ 'contact/web/Amazon',
+ 'contact/web/Flickr',
+ 'contact/web/Delicious',*/
+ 'company/name',
+ 'company/title',
+ /*'media/spokenname',
+ 'media/greeting/audio',
+ 'media/greeting/video',
+ 'media/biography',
+ 'media/image',
+ 'media/image/16x16',
+ 'media/image/32x32',
+ 'media/image/48x48',
+ 'media/image/64x64',
+ 'media/image/80x80',
+ 'media/image/128x128',
+ 'media/image/160x120',
+ 'media/image/320x240',
+ 'media/image/640x480',
+ 'media/image/120x160',
+ 'media/image/240x320',
+ 'media/image/480x640',
+ 'media/image/favicon',
+ 'timezone',*/
+ );
+
+ # redirect the user to the provider authentication url
+ Hybrid_Auth::redirect( $this->api->authUrl() );
+ }
+}
+
diff --git a/hauth/Hybrid/Providers/Yahoo.php b/hauth/Hybrid/Providers/Yahoo.php
index 81c4828..82e3972 100644
--- a/hauth/Hybrid/Providers/Yahoo.php
+++ b/hauth/Hybrid/Providers/Yahoo.php
@@ -28,7 +28,7 @@ class Hybrid_Providers_Yahoo extends Hybrid_Provider_Model_OAuth2 {
* If empty will be used YDN App scopes.
* @see https://developer.yahoo.com/oauth2/guide/yahoo_scopes.
*/
- public $scope = [];
+ public $scope = array();
/**
* {@inheritdoc}
diff --git a/hauth/Hybrid/thirdparty/Paypal/PaypalOAuth2Client.php b/hauth/Hybrid/thirdparty/Paypal/PaypalOAuth2Client.php
deleted file mode 100644
index 150c735..0000000
--- a/hauth/Hybrid/thirdparty/Paypal/PaypalOAuth2Client.php
+++ /dev/null
@@ -1,142 +0,0 @@
-<?php
-/*!
-* HybridAuth
-* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
-* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
-*/
-
-// A service client for the OAuth 2 flow.
-// v0.1
-class PaypalOAuth2Client extends OAuth2Client
-{
- public $curl_header = array(
- 'Accept: application/json',
- 'Accept-Language: en_US',
- );
- public $curl_useragent = "OAuth/2 Simple PHP Client v0.1; HybridAuth http://hybridauth.sourceforge.net/";
- public $curl_log;
-
- public function authenticate( $code )
- {
- $params = array(
- "grant_type" => "authorization_code",
- "code" => $code,
- "redirect_uri" => $this->redirect_uri,
- );
-
- $response = $this->request( $this->token_url, $params, $this->curl_authenticate_method );
-
- $response = $this->parseRequestResult( $response );
-
- if( ! $response || ! isset( $response->access_token ) ){
- throw new Exception( "The Authorization Service has return: " . $response->message );
- }
-
- if( isset( $response->access_token ) ) $this->access_token = $response->access_token;
- if( isset( $response->refresh_token ) ) $this->refresh_token = $response->refresh_token;
- if( isset( $response->expires_in ) ) $this->access_token_expires_in = $response->expires_in;
-
- // calculate when the access token expire
- if( isset($response->expires_in)) {
- $this->access_token_expires_at = time() + $response->expires_in;
- }
-
- return $response;
- }
-
-
- // -- tokens
-
- public function tokenInfo($accesstoken)
- {
- $params['access_token'] = $this->access_token;
- $response = $this->request( $this->token_info_url, $params, "POST" );
- return $this->parseRequestResult( $response );
- }
-
- public function refreshToken( $params = array() )
- {
- $params = array(
- "grant_type" => "refresh_token",
- "refresh_token" => $this->refresh_token,
- );
- $response = $this->request( $this->token_url, $params, "POST" );
- return $this->parseRequestResult( $response );
- }
-
- // -- utilities
-
- private function request( $url, $params=false, $type="GET" )
- {
- $params = http_build_query($params, '', '&');
- Hybrid_Logger::info( "Enter OAuth2Client::request( $url )" );
- Hybrid_Logger::debug( "OAuth2Client::request(). dump request params: ", $params );
-
- if( $type == "GET" ){
- $url = $url . ( strpos( $url, '?' ) ? '&' : '?' ) . $params;
- }
-
- $this->http_info = array();
- $ch = curl_init();
-
- $headers = $this->curl_header;
- if($type == "POST" ){
- //$headers[] = 'Content-Type: application/x-www-form-urlencoded';
- }
-
- curl_setopt($ch, CURLOPT_URL , $url );
- curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1 );
- curl_setopt($ch, CURLOPT_TIMEOUT , $this->curl_time_out );
- curl_setopt($ch, CURLOPT_USERAGENT , $this->curl_useragent );
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , $this->curl_connect_time_out );
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , $this->curl_ssl_verifypeer );
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST , $this->curl_ssl_verifyhost );
- curl_setopt($ch, CURLOPT_HTTPHEADER , $headers );
- curl_setopt($ch, CURLOPT_USERPWD , $this->client_id.':'.$this->client_secret );
- // logging
- if ($this->curl_log !== null) {
- $fp = fopen($this->curl_log, 'a');
- curl_setopt($ch, CURLOPT_STDERR , $fp );
- curl_setopt($ch, CURLOPT_VERBOSE , 1 );
- }
-
- if($this->curl_proxy){
- curl_setopt( $ch, CURLOPT_PROXY , $this->curl_proxy);
- }
-
- if( $type == "POST" ){
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params );
- }
-
- $response = curl_exec($ch);
- if ($this->curl_log !== null)
- fclose($fp);
- if( $response === FALSE ) {
- Hybrid_Logger::error( "OAuth2Client::request(). curl_exec error: ", curl_error($ch) );
- }
- Hybrid_Logger::debug( "OAuth2Client::request(). dump request info: ", serialize( curl_getinfo($ch) ) );
- Hybrid_Logger::debug( "OAuth2Client::request(). dump request result: ", serialize( $response ) );
-
- $this->http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- $this->http_info = array_merge($this->http_info, curl_getinfo($ch));
-
- curl_close ($ch);
-
- return $response;
- }
-
- private function parseRequestResult( $result )
- {
- if( json_decode( $result ) ) return json_decode( $result );
-
- parse_str( $result, $output );
-
- $result = new StdClass();
-
- foreach( $output as $k => $v )
- $result->$k = $v;
-
- return $result;
- }
-}