Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
chuprik committed Jan 25, 2015
0 parents commit 63e468b
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .gitignore
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
57 changes: 57 additions & 0 deletions Instagram.php
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';
}
}
47 changes: 47 additions & 0 deletions README.md
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
],
],
// ...
]
```
22 changes: 22 additions & 0 deletions composer.json
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"
}

0 comments on commit 63e468b

Please sign in to comment.