From 63e468b402b0a2b5cf31d03cdf0eaac713a1ed7f Mon Sep 17 00:00:00 2001 From: Constantin Chuprik Date: Mon, 26 Jan 2015 01:16:17 +0600 Subject: [PATCH] initial --- .gitignore | 23 +++++++++++++++++++++ Instagram.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 47 ++++++++++++++++++++++++++++++++++++++++++ composer.json | 22 ++++++++++++++++++++ 4 files changed, 149 insertions(+) create mode 100644 .gitignore create mode 100644 Instagram.php create mode 100644 README.md create mode 100644 composer.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..466db73 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/Instagram.php b/Instagram.php new file mode 100644 index 0000000..beed149 --- /dev/null +++ b/Instagram.php @@ -0,0 +1,57 @@ +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'; + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..6b8c107 --- /dev/null +++ b/README.md @@ -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 + ], + ], + // ... + ] + ``` \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..e5d513e --- /dev/null +++ b/composer.json @@ -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": "constantinchuprik@gmail.com" + } + ], + "autoload": { + "psr-4": { + "kotchuprik\\authclient\\": "" + } + }, + "minimum-stability": "dev" +}