Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
10582 lgm 1
<?php
2
/**
3
 * Foursquare OAuth2 Provider
4
 *
5
 * @package    CodeIgniter/OAuth2
6
 * @category   Provider
7
 * @author     Phil Sturgeon
8
 * @copyright  (c) 2012 HappyNinjas Ltd
9
 * @license    http://philsturgeon.co.uk/code/dbad-license
10
 */
11
 
12
class OAuth2_Provider_Foursquare extends OAuth2_Provider
13
{  
14
	public $method = 'POST';
15
 
16
	public function url_authorize()
17
	{
18
		return 'https://foursquare.com/oauth2/authenticate';
19
	}
20
 
21
	public function url_access_token()
22
	{
23
		return 'https://foursquare.com/oauth2/access_token';
24
	}
25
 
26
	public function get_user_info(OAuth2_Token_Access $token)
27
	{
28
		$url = 'https://api.foursquare.com/v2/users/self?'.http_build_query(array(
29
			'oauth_token' => $token->access_token,
30
		));
31
 
32
		$response = json_decode(file_get_contents($url));
33
 
34
		$user = $response->response->user;
35
 
36
		// Create a response from the request
37
		return array(
38
			'uid' => $user->id,
39
			//'nickname' => $user->login,
40
			'name' => sprintf('%s %s', $user->firstName, $user->lastName),
41
			'email' => $user->contact->email,
42
			'image' => $user->photo,
43
			'location' => $user->homeCity,
44
		);
45
	}
46
}