summaryrefslogtreecommitdiffstats
path: root/includes/HybridAuth/Providers/Foursquare.php
diff options
context:
space:
mode:
authorBlueRaja <BlueRaja.admin@gmail.com>2013-06-01 20:10:36 -0500
committerBlueRaja <BlueRaja.admin@gmail.com>2013-06-01 20:10:36 -0500
commit951330c9f83c8c8ee98f65fdccb5797e2e59d1f3 (patch)
treefc7b196ca0d91c1c71dcd945aa9667c7af0134fa /includes/HybridAuth/Providers/Foursquare.php
parente58a3b8b3702b22c903b02a9b4fa1020d6797459 (diff)
downloadpathery-951330c9f83c8c8ee98f65fdccb5797e2e59d1f3.tar.xz
A partial commit of the auth stuff, in case my upcoming changes break anything
Diffstat (limited to 'includes/HybridAuth/Providers/Foursquare.php')
-rw-r--r--includes/HybridAuth/Providers/Foursquare.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/includes/HybridAuth/Providers/Foursquare.php b/includes/HybridAuth/Providers/Foursquare.php
new file mode 100644
index 0000000..a87cacf
--- /dev/null
+++ b/includes/HybridAuth/Providers/Foursquare.php
@@ -0,0 +1,56 @@
+<?php
+/*!
+* HybridAuth
+* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
+* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
+*/
+
+/**
+ * Hybrid_Providers_Foursquare provider adapter based on OAuth2 protocol
+ *
+ * http://hybridauth.sourceforge.net/userguide/IDProvider_info_Foursquare.html
+ */
+class Hybrid_Providers_Foursquare extends Hybrid_Provider_Model_OAuth2
+{
+ /**
+ * IDp wrappers initializer
+ */
+ function initialize()
+ {
+ parent::initialize();
+
+ // Provider apis end-points
+ $this->api->api_base_url = "https://api.foursquare.com/v2/";
+ $this->api->authorize_url = "https://foursquare.com/oauth2/authenticate";
+ $this->api->token_url = "https://foursquare.com/oauth2/access_token";
+
+ $this->api->sign_token_name = "oauth_token";
+ }
+
+ /**
+ * load the user profile from the IDp api client
+ */
+ function getUserProfile()
+ {
+ $data = $this->api->api( "users/self" );
+
+ if ( ! isset( $data->response->user->id ) ){
+ throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
+ }
+
+ $data = $data->response->user;
+
+ $this->user->profile->identifier = $data->id;
+ $this->user->profile->firstName = $data->firstName;
+ $this->user->profile->lastName = $data->lastName;
+ $this->user->profile->displayName = trim( $this->user->profile->firstName . " " . $this->user->profile->lastName );
+ $this->user->profile->photoURL = $data->photo;
+ $this->user->profile->profileURL = "https://www.foursquare.com/user/" . $data->id;
+ $this->user->profile->gender = $data->gender;
+ $this->user->profile->city = $data->homeCity;
+ $this->user->profile->email = $data->contact->email;
+ $this->user->profile->emailVerified = $data->contact->email;
+
+ return $this->user->profile;
+ }
+}