Line | |
---|
1 | <?php |
---|
2 | /*! |
---|
3 | * HybridAuth |
---|
4 | * http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth |
---|
5 | * (c) 2009-2012 HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html |
---|
6 | */ |
---|
7 | |
---|
8 | /** |
---|
9 | * Hybrid_Providers_Instagram (By Sebastian Lasse - https://github.com/sebilasse) |
---|
10 | */ |
---|
11 | class Hybrid_Providers_Instagram extends Hybrid_Provider_Model_OAuth2 |
---|
12 | { |
---|
13 | // default permissions |
---|
14 | public $scope = "basic"; |
---|
15 | |
---|
16 | /** |
---|
17 | * IDp wrappers initializer |
---|
18 | */ |
---|
19 | function initialize() |
---|
20 | { |
---|
21 | parent::initialize(); |
---|
22 | |
---|
23 | // Provider api end-points |
---|
24 | $this->api->api_base_url = "https://api.instagram.com/v1/"; |
---|
25 | $this->api->authorize_url = "https://api.instagram.com/oauth/authorize/"; |
---|
26 | $this->api->token_url = "https://api.instagram.com/oauth/access_token"; |
---|
27 | } |
---|
28 | |
---|
29 | /** |
---|
30 | * load the user profile from the IDp api client |
---|
31 | */ |
---|
32 | function getUserProfile(){ |
---|
33 | $data = $this->api->api("users/self/" ); |
---|
34 | |
---|
35 | if ( $data->meta->code != 200 ){ |
---|
36 | throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 ); |
---|
37 | } |
---|
38 | |
---|
39 | $this->user->profile->identifier = $data->data->id; |
---|
40 | $this->user->profile->displayName = $data->data->full_name ? $data->data->full_name : $data->data->username; |
---|
41 | $this->user->profile->description = $data->data->bio; |
---|
42 | $this->user->profile->photoURL = $data->data->profile_picture; |
---|
43 | |
---|
44 | $this->user->profile->webSiteURL = $data->data->website; |
---|
45 | |
---|
46 | return $this->user->profile; |
---|
47 | } |
---|
48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.