-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 63e468b
Showing
4 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# phpstorm project files | ||
.idea | ||
|
||
# netbeans project files | ||
nbproject | ||
|
||
# zend studio for eclipse project files | ||
.buildpath | ||
.project | ||
.settings | ||
|
||
# windows thumbnail cache | ||
Thumbs.db | ||
|
||
# composer vendor dir | ||
/vendor | ||
|
||
# composer itself is not needed | ||
composer.phar | ||
composer.lock | ||
|
||
# Mac DS_Store Files | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace kotchuprik\authclient; | ||
|
||
use yii\authclient\OAuth2; | ||
|
||
class Instagram extends OAuth2 | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public $authUrl = 'https://api.instagram.com/oauth/authorize'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public $tokenUrl = 'https://api.instagram.com/oauth/access_token'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public $apiBaseUrl = 'https://api.instagram.com/v1'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function initUserAttributes() | ||
{ | ||
$response = $this->api('users/self', 'GET'); | ||
|
||
return $response['data']; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function apiInternal($accessToken, $url, $method, array $params, array $headers) | ||
{ | ||
return $this->sendRequest($method, $url . '?access_token=' . $accessToken->getToken(), $params, $headers); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function defaultName() | ||
{ | ||
return 'instagram'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function defaultTitle() | ||
{ | ||
return 'Instagram'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# yii2-instagram-authclient | ||
|
||
This extension adds Instagram OAuth2 supporting for [yii2-authclient](https://github.com/yiisoft/yii2-authclient). | ||
|
||
## Installation | ||
|
||
The preferred way to install this extension is through [composer](http://getcomposer.org/download/). | ||
|
||
Either run | ||
|
||
``` | ||
php composer.phar require --prefer-dist kotchuprik/yii2-instagram-authclient "*" | ||
``` | ||
|
||
or add | ||
|
||
```json | ||
"kotchuprik/yii2-instagram-authclient": "*" | ||
``` | ||
|
||
to the `require` section of your composer.json. | ||
|
||
## Usage | ||
|
||
You must read the yii2-authclient [docs](https://github.com/yiisoft/yii2/blob/master/docs/guide/security-auth-clients.md) | ||
|
||
Register your application [in Instagram](http://instagram.com/developer/clients/register) | ||
|
||
and add the Instagram client to your auth clients. | ||
|
||
```php | ||
'components' => [ | ||
'authClientCollection' => [ | ||
'class' => 'yii\authclient\Collection', | ||
'clients' => [ | ||
'instagram' => [ | ||
'class' => 'kotchuprik\authclient\Instagram', | ||
'consumerKey' => 'instagram_client_id', | ||
'consumerSecret' => 'instagram_client_secret', | ||
], | ||
], | ||
// other clients | ||
], | ||
], | ||
// ... | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "kotchuprik/yii2-instagram-authclient", | ||
"description": "Instagram extenion for using via yii2-authclient", | ||
"keywords": ["yii2", "authclient", "oauth", "instagram"], | ||
"homepage": "http://github.com/kotchuprik/yii2-instagram-authclient", | ||
"require": { | ||
"yiisoft/yii2-authclient": "~2.0@dev" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Constantin Chuprik", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"kotchuprik\\authclient\\": "" | ||
} | ||
}, | ||
"minimum-stability": "dev" | ||
} |