Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12694 anikendra 1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2
/**
3
 * Soundcloud 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_Soundcloud extends OAuth2_Provider
13
{	
14
	/**
15
	 * @var  string  the method to use when requesting tokens
16
	 */
17
	protected $method = 'POST';
18
 
19
	public function url_authorize()
20
	{
21
		return 'https://soundcloud.com/connect';
22
	}
23
 
24
	public function url_access_token()
25
	{
26
		return 'https://api.soundcloud.com/oauth2/token';
27
	}
28
 
29
	public function get_user_info(OAuth2_Token_Access $token)
30
	{
31
		$url = 'https://api.soundcloud.com/me.json?'.http_build_query(array(
32
			'oauth_token' => $token->access_token,
33
		));
34
 
35
		$user = json_decode(file_get_contents($url));
36
 
37
		// Create a response from the request
38
		return array(
39
			'uid' => $user->id,
40
			'nickname' => $user->username,
41
			'name' => $user->full_name,
42
			'location' => $user->country.' ,'.$user->country,
43
			'description' => $user->description,
44
			'image' => $user->avatar_url,
45
			'urls' => array(
46
				'MySpace' => $user->myspace_name,
47
				'Website' => $user->website,
48
			),
49
		);
50
	}
51
}