Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
10582 lgm 1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
/**
3
 * PayPal 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_Paypal extends OAuth2_Provider
13
{
14
    /**
15
     * @var  string  default scope (useful if a scope is required for user info)
16
     */
17
    protected $scope = array('https://identity.x.com/xidentity/resources/profile/me');
18
 
19
    /**
20
     * @var  string  the method to use when requesting tokens
21
     */
22
    protected $method = 'POST';
23
 
24
    public function url_authorize()
25
    {
26
        return 'https://identity.x.com/xidentity/resources/authorize';
27
    }
28
 
29
    public function url_access_token()
30
    {
31
        return 'https://identity.x.com/xidentity/oauthtokenservice';
32
    }
33
 
34
    public function get_user_info(OAuth2_Token_Access $token)
35
    {
36
        $url = 'https://identity.x.com/xidentity/resources/profile/me?' . http_build_query(array(
37
            'oauth_token' => $token->access_token
38
        ));
39
 
40
        $user = json_decode(file_get_contents($url));
41
		$user = $user->identity;
42
 
43
		return array(
44
            'uid' => $user['userId'],
45
            'nickname' => url_title($user['fullName'], '_', true),
46
            'name' => $user['fullName'],
47
            'first_name' => $user['firstName'],
48
            'last_name' => $user['lastName'],
49
            'email' => $user['emails'][0],
50
            'location' => $user->addresses[0],
51
            'image' => null,
52
            'description' => null,
53
            'urls' => array(
54
				'PayPal' => null
55
			)
56
        );
57
    }
58
 
59
}