From 2cd148c792a47fea18d760b723d23569ae52d390 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Wed, 24 Dec 2014 16:44:44 -0800 Subject: Support for "likes" and adding "settings" page * Supports a bookmarklet to create "like" posts. * Beginning a "settings" page to connect silo profiles for POSSEing likes to twitter, facebook and instagram --- composer.lock | 67 ++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 19 deletions(-) (limited to 'composer.lock') diff --git a/composer.lock b/composer.lock index a4e4ad6..0bdac28 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "3e034e0a6a692d5bbfecfdc95ee69db2", + "hash": "502847c033f5a54c69a6a1a51d26e894", "packages": [ { "name": "firebase/php-jwt", @@ -12,12 +12,12 @@ "source": { "type": "git", "url": "https://github.com/firebase/php-jwt.git", - "reference": "53669d621149e49c2a428722a62acfef3342c260" + "reference": "83b8899cb73d85d648af93f37ec0ac89f4a5bbae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/firebase/php-jwt/zipball/53669d621149e49c2a428722a62acfef3342c260", - "reference": "53669d621149e49c2a428722a62acfef3342c260", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/83b8899cb73d85d648af93f37ec0ac89f4a5bbae", + "reference": "83b8899cb73d85d648af93f37ec0ac89f4a5bbae", "shasum": "" }, "require": { @@ -26,7 +26,8 @@ "type": "library", "autoload": { "classmap": [ - "Authentication/" + "Authentication/", + "Exceptions/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -47,7 +48,7 @@ ], "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", "homepage": "https://github.com/firebase/php-jwt", - "time": "2013-09-03 20:55:18" + "time": "2014-11-18 17:58:25" }, { "name": "indieauth/client", @@ -367,6 +368,41 @@ ], "time": "2013-09-23 22:51:48" }, + { + "name": "ruudk/twitter-oauth", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/ruudk/twitteroauth.git", + "reference": "7f5a94eaa1572ddbc7f0a32ba3b865b8ac23712a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ruudk/twitteroauth/zipball/7f5a94eaa1572ddbc7f0a32ba3b865b8ac23712a", + "reference": "7f5a94eaa1572ddbc7f0a32ba3b865b8ac23712a", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "authors": [ + { + "name": "Ruud Kamphuis", + "email": "ruud@1plus1media.nl", + "role": "Developer" + } + ], + "description": "PHP 5.3 version of abraham/twitteroauth", + "homepage": "http://github.com/ruudk/twitteroauth", + "time": "2014-06-10 18:17:38" + }, { "name": "saltybeagle/savant3", "version": "dev-master", @@ -446,21 +482,14 @@ "time": "2012-12-13 02:15:50" } ], - "packages-dev": [ - - ], - "aliases": [ - - ], + "packages-dev": [], + "aliases": [], "minimum-stability": "stable", "stability-flags": { "saltybeagle/savant3": 20, - "firebase/php-jwt": 20 + "firebase/php-jwt": 20, + "ruudk/twitter-oauth": 20 }, - "platform": [ - - ], - "platform-dev": [ - - ] + "platform": [], + "platform-dev": [] } -- cgit v1.2.3 From 430609b9005bb93ce2c6b21405cea0ede2b17a9d Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Thu, 25 Dec 2014 18:50:34 -0800 Subject: adds instagram auth --- composer.json | 3 ++- composer.lock | 45 ++++++++++++++++++++++++++++++++++++++++++++- controllers/controllers.php | 40 ++++++++++++++++++++++++++++++++++++++++ lib/helpers.php | 11 +++++++++++ views/settings.php | 31 +++++++++++++++++++++++++------ 5 files changed, 122 insertions(+), 8 deletions(-) (limited to 'composer.lock') diff --git a/composer.json b/composer.json index a7dbea7..cf2f57e 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,8 @@ "indieauth/client": "0.1.3", "mpratt/relativetime": ">=1.0", "firebase/php-jwt": "dev-master", - "ruudk/twitter-oauth": "dev-master" + "ruudk/twitter-oauth": "dev-master", + "andreyco/instagram": "3.*" }, "autoload": { "files": [ diff --git a/composer.lock b/composer.lock index 0bdac28..eb3dfc1 100644 --- a/composer.lock +++ b/composer.lock @@ -3,8 +3,51 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "502847c033f5a54c69a6a1a51d26e894", + "hash": "f2f8fdb671b52ce22dc0a5e133f9a13d", "packages": [ + { + "name": "andreyco/instagram", + "version": "v3.2", + "source": { + "type": "git", + "url": "https://github.com/Andreyco/Instagram-for-PHP.git", + "reference": "726e724c51301410873d9bae9c659a0597ca47e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Andreyco/Instagram-for-PHP/zipball/726e724c51301410873d9bae9c659a0597ca47e4", + "reference": "726e724c51301410873d9bae9c659a0597ca47e4", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Andreyco\\Instagram\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-4-Clause" + ], + "authors": [ + { + "name": "Andrej Badin", + "email": "contact@andrejbadin.com", + "homepage": "http://andrejbadin.com" + } + ], + "description": "An easy-to-use PHP Class for accessing Instagram's API.", + "homepage": "https://github.com/Andreyco/Instagram", + "keywords": [ + "api", + "instagram" + ], + "time": "2014-07-14 19:53:19" + }, { "name": "firebase/php-jwt", "version": "dev-master", diff --git a/controllers/controllers.php b/controllers/controllers.php index 18da149..47fd614 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -333,3 +333,43 @@ $app->get('/auth/twitter/callback', function() use($app) { $app->redirect('/settings'); } }); + +$app->get('/auth/instagram', function() use($app) { + if($user=require_login($app, false)) { + + $instagram = instagram_client(); + + // If there is an existing Instagram auth token, check if it's valid + if($user->instagram_access_token) { + $instagram->setAccessToken($user->instagram_access_token); + $igUser = $instagram->getUser(); + + if($igUser && $igUser->meta->code == 200) { + $app->response()->body(json_encode(array( + 'result' => 'ok', + 'username' => $igUser->data->username + ))); + return; + } + } + + $app->response()->body(json_encode(array( + 'result' => 'error', + 'url' => $instagram->getLoginUrl(array('basic','likes')) + ))); + } +}); + +$app->get('/auth/instagram/callback', function() use($app) { + if($user=require_login($app)) { + $params = $app->request()->params(); + + $instagram = instagram_client(); + $data = $instagram->getOAuthToken($params['code']); + $user->instagram_access_token = $data->access_token; + $user->save(); + + $app->redirect('/settings'); + } +}); + diff --git a/lib/helpers.php b/lib/helpers.php index 010bd91..456fcfd 100644 --- a/lib/helpers.php +++ b/lib/helpers.php @@ -195,3 +195,14 @@ function relative_time($date) { } return $rel->timeAgo($date); } + +function instagram_client() { + return new Andreyco\Instagram\Client(array( + 'apiKey' => Config::$instagramClientID, + 'apiSecret' => Config::$instagramClientSecret, + 'apiCallback' => Config::$base_url . 'auth/instagram/callback', + 'scope' => array('basic','likes'), + )); +} + + diff --git a/views/settings.php b/views/settings.php index 61feefc..9860a91 100644 --- a/views/settings.php +++ b/views/settings.php @@ -10,11 +10,8 @@

Twitter

- - + -- cgit v1.2.3