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
 * Windows Live 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_Windowslive extends OAuth2_Provider
13
{	
14
	protected $scope = array('wl.basic', 'wl.emails');
15
 
16
	/**
17
	 * @var  string  the method to use when requesting tokens
18
	 */
19
	protected $method = 'POST';
20
 
21
	// authorise url
22
	public function url_authorize()
23
	{
24
		return 'https://oauth.live.com/authorize';
25
	}
26
 
27
	// access token url
28
	public function url_access_token()
29
	{
30
		return 'https://oauth.live.com/token';
31
	}
32
 
33
	// get basic user information
34
	/********************************
35
	** this can be extended through the 
36
	** use of scopes, check out the document at
37
	** http://msdn.microsoft.com/en-gb/library/hh243648.aspx#user
38
	*********************************/
39
	public function get_user_info(OAuth2_Token_Access $token)
40
	{
41
		// define the get user information token
42
		$url = 'https://apis.live.net/v5.0/me?'.http_build_query(array(
43
			'access_token' => $token->access_token,
44
		));
45
 
46
		// perform network request
47
		$user = json_decode(file_get_contents($url));
48
 
49
		// create a response from the request and return it
50
		return array(
51
			'uid' 		=> $user->id,
52
			'name' 		=> $user->name,
53
			'nickname' 	=> url_title($user->name, '_', true),
54
//			'location' 	=> $user[''], # scope wl.postal_addresses is required
55
										  # but won't be implemented by default
56
			'locale' 	=> $user->locale,
57
			'urls' 		=> array('Windows Live' => $user->link),
58
		);
59
	}
60
}