Merge pull request #15 from msurguy/master
Added instagram to the providers and added a new row to readme1.0
commit
fb66f279f8
|
@ -13,7 +13,7 @@ The library requires PHP 5.3+ and is PSR-0 compatible.
|
|||
## Usage
|
||||
|
||||
```php
|
||||
$provider = new \OAuth2\Client\Provider\<provider name>(array(
|
||||
$provider = new League\OAuth2\Client\Provider\<provider name>(array(
|
||||
'clientId' => 'XXXXXXXX',
|
||||
'clientSecret' => 'XXXXXXXX',
|
||||
'redirectUri' => 'http://your-registered-redirect-uri/'
|
||||
|
@ -61,5 +61,6 @@ if ( ! isset($_GET['code'])) {
|
|||
| **Facebook** | string | string | string | string | string | string | string | string | string | array (Facebook) |
|
||||
| **Github** | string | string | string | null | null | string | null | null | null | array (Github, [personal])|
|
||||
| **Google** | string | string | string | string | string | string | null | null | string | null |
|
||||
| **Instagram** | string | string | string | null | null | null | null | string | string | null |
|
||||
|
||||
**Notes**: Providers which return URLs sometimes include additional URLs if the user has provided them. These have been wrapped in []
|
||||
**Notes**: Providers which return URLs sometimes include additional URLs if the user has provided them. These have been wrapped in []
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace League\OAuth2\Client\Provider;
|
||||
|
||||
class Instagram extends IdentityProvider
|
||||
{
|
||||
public $scopes = array('basic');
|
||||
public $responseType = 'json';
|
||||
|
||||
public function urlAuthorize()
|
||||
{
|
||||
return 'https://api.instagram.com/oauth/authorize';
|
||||
}
|
||||
|
||||
public function urlAccessToken()
|
||||
{
|
||||
return 'https://api.instagram.com/oauth/access_token';
|
||||
}
|
||||
|
||||
public function urlUserDetails(\League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
return 'https://api.instagram.com/v1/users/self?access_token='.$token;
|
||||
}
|
||||
|
||||
public function userDetails($response, \League\OAuth2\Client\Token\AccessToken $token)
|
||||
{
|
||||
|
||||
$user = new User;
|
||||
|
||||
$user->uid = $response->data->id;
|
||||
$user->nickname = $response->data->username;
|
||||
$user->name = $response->data->full_name;
|
||||
$user->description = isset($response->data->bio) ? $response->data->bio : null;
|
||||
$user->imageUrl = $response->data->profile_picture;
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue