From 7d19f61b101ca30debc675018f5509fb28e3de1a Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Sat, 17 Dec 2016 15:30:58 -0800 Subject: [PATCH] remove facebook/instagram stuff --- controllers/auth.php | 61 ---------------------------- controllers/controllers.php | 70 +++----------------------------- lib/config.template.php | 4 -- views/favorite-js.php | 33 --------------- views/favorite-popup.php | 50 ----------------------- views/layout.php | 6 --- views/partials/fb-script.php | 20 --------- views/privacy.php | 4 +- views/settings.php | 79 ++---------------------------------- 9 files changed, 11 insertions(+), 316 deletions(-) delete mode 100644 views/favorite-js.php delete mode 100644 views/favorite-popup.php delete mode 100644 views/partials/fb-script.php diff --git a/controllers/auth.php b/controllers/auth.php index f339ed4..c4efb1d 100644 --- a/controllers/auth.php +++ b/controllers/auth.php @@ -256,25 +256,6 @@ $app->get('/signout', function() use($app) { }); -/* -$app->post('/auth/facebook', function() use($app) { - if($user=require_login($app, false)) { - $params = $app->request()->params(); - // User just auth'd with facebook, store the access token - $user->facebook_access_token = $params['fb_token']; - $user->save(); - - $app->response()->body(json_encode(array( - 'result' => 'ok' - ))); - } else { - $app->response()->body(json_encode(array( - 'result' => 'error' - ))); - } -}); -*/ - $app->post('/auth/twitter', function() use($app) { if($user=require_login($app, false)) { $params = $app->request()->params(); @@ -360,45 +341,3 @@ $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()['Content-type'] = 'application/json'; - $app->response()->body(json_encode(array( - 'result' => 'ok', - 'username' => $igUser->data->username, - 'url' => $instagram->getLoginUrl(array('basic','likes')) - ))); - return; - } - } - - $app->response()['Content-type'] = 'application/json'; - $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/controllers/controllers.php b/controllers/controllers.php index d6cad4f..1b832b9 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -314,7 +314,11 @@ $app->get('/email', function() use($app) { $app->get('/settings', function() use($app) { if($user=require_login($app)) { - $html = render('settings', array('title' => 'Settings', 'include_facebook' => true, 'authorizing' => false)); + $html = render('settings', [ + 'title' => 'Settings', + 'user' => $user, + 'authorizing' => false + ]); $app->response()->body($html); } }); @@ -339,54 +343,15 @@ $app->get('/settings/html-content', function() use($app) { } }); -$app->get('/favorite-popup', function() use($app) { - if($user=require_login($app)) { - $params = $app->request()->params(); - - $html = $app->render('favorite-popup.php', array( - 'url' => $params['url'], - 'token' => $params['token'] - )); - $app->response()->body($html); - } -}); - function create_favorite(&$user, $url) { $micropub_request = array( 'like-of' => $url ); $r = micropub_post_for_user($user, $micropub_request); - $facebook_id = false; - $instagram_id = false; $tweet_id = false; - /* - // Facebook likes are posted via Javascript, so pass the FB ID to the javascript code - if(preg_match('/https?:\/\/(?:www\.)?facebook\.com\/(?:[^\/]+)\/posts\/(\d+)/', $url, $match)) { - $facebook_id = $match[1]; - } - - if(preg_match('/https?:\/\/(?:www\.)?facebook\.com\/photo\.php\?fbid=(\d+)/', $url, $match)) { - $facebook_id = $match[1]; - } - */ - - if(preg_match('/https?:\/\/(?:www\.)?instagram\.com\/p\/([^\/]+)/', $url, $match)) { - $instagram_id = $match[1]; - if($user->instagram_access_token) { - $instagram = instagram_client(); - $instagram->setAccessToken($user->instagram_access_token); - $ch = curl_init('https://api.instagram.com/v1/media/shortcode/' . $instagram_id . '?access_token=' . $user->instagram_access_token); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - $result = json_decode(curl_exec($ch)); - - $result = $instagram->likeMedia($result->data->id); - } else { - // TODO: indicate that the instagram post couldn't be liked because no access token was available - } - } - + // POSSE favorites to Twitter if($user->twitter_access_token && preg_match('/https?:\/\/(?:www\.)?twitter\.com\/[^\/]+\/status(?:es)?\/(\d+)/', $url, $match)) { $tweet_id = $match[1]; $twitter = new \TwitterOAuth\Api(Config::$twitterClientID, Config::$twitterClientSecret, @@ -417,29 +382,6 @@ function create_repost(&$user, $url) { return $r; } -$app->get('/favorite.js', function() use($app) { - $app->response()->header("Content-type", "text/javascript"); - if($user=require_login($app, false)) { - $params = $app->request()->params(); - - if(array_key_exists('url', $params)) { - $r = create_favorite($user, $params['url']); - - $app->response()->body($app->render('favorite-js.php', array( - 'url' => $params['url'], - 'like_url' => $r['location'], - 'error' => $r['error'], - // 'facebook_id' => $facebook_id - ))); - } else { - $app->response()->body('alert("no url");'); - } - - } else { - $app->response()->body('alert("invalid token");'); - } -}); - $app->post('/favorite', function() use($app) { if($user=require_login($app)) { $params = $app->request()->params(); diff --git a/lib/config.template.php b/lib/config.template.php index 87ce75b..50d3b12 100644 --- a/lib/config.template.php +++ b/lib/config.template.php @@ -17,11 +17,7 @@ class Config { public static $jwtSecret = 'xxx'; - public static $fbClientID = ''; - public static $fbClientSecret = ''; public static $twitterClientID = ''; public static $twitterClientSecret = ''; - public static $instagramClientID = ''; - public static $instagramClientSecret = ''; } diff --git a/views/favorite-js.php b/views/favorite-js.php deleted file mode 100644 index 4ce6dba..0000000 --- a/views/favorite-js.php +++ /dev/null @@ -1,33 +0,0 @@ - -console.log("Favoriting URL: url ?>"); - -var css = document.createElement('link'); -css.rel="stylesheet"; -css.type="text/css"; -css.href="css/favorite.css"; -document.body.appendChild(css); - -function show_star() { - var star = document.createElement('img'); - star.id="quill-star"; - star.src="images/like_url ? 'star' : 'red-x' ?>.svg"; - star.onload=function() { - setTimeout(function(){ - - document.getElementById('quill-star').classList.add('hidden'); - var el = document.getElementById('quill-star'); - el.parentNode.removeChild(el); - if(typeof favorite_finished == "function") { - favorite_finished(); - } else { - // For now, redirect the user to the URL of their favorite so they can see it posted. - // Might want to change this later. - window.location = "like_url ?>"; - } - - }, 1200); - } - document.body.appendChild(star); -} - -show_star(); diff --git a/views/favorite-popup.php b/views/favorite-popup.php deleted file mode 100644 index fecc780..0000000 --- a/views/favorite-popup.php +++ /dev/null @@ -1,50 +0,0 @@ - - - - Favoriting - - - - - - - window.quillFbInit = function() { - FB.getLoginStatus(function(response) { - - if (response.status === 'connected') { - // the user is logged in and has authenticated your - // app, and response.authResponse supplies - // the user's ID, a valid access token, a signed - // request, and the time the access token - // and signed request each expire - var uid = response.authResponse.userID; - var accessToken = response.authResponse.accessToken; - console.log(accessToken); - - FB.api("/facebook_id ?>/likes", "post", function(response){ - console.log(response); - show_star(); - }); - - } else if (response.status === 'not_authorized') { - // the user is logged in to Facebook, - // but has not authenticated your app - console.log("Logged in but not authorized"); - } else { - // the user isn't logged in to Facebook. - console.log("User isn't logged in"); - } - }); - }; - - - */ ?> - - - - \ No newline at end of file diff --git a/views/layout.php b/views/layout.php index f953dc2..9fad319 100644 --- a/views/layout.php +++ b/views/layout.php @@ -40,12 +40,6 @@ - - \ No newline at end of file diff --git a/views/privacy.php b/views/privacy.php index acdf235..40ce393 100644 --- a/views/privacy.php +++ b/views/privacy.php @@ -3,10 +3,10 @@

Privacy Policy

-

Quill enables you to post text, bookmarks and likes to your own wbesite

+

Quill enables you to post text, bookmarks, likes, and other kinds of posts to your own wbesite

Quill does not store your posts itself, but does cache the last response from your website and provides it to you for debugging purposes.

-

If you connect Quill to your Facebook or Twitter account, Quill can post to those sites on your behalf. Quill will never post anything to your accounts without an explicit action on your part.

+

If you connect Quill to your Twitter account, Quill can favorite tweets on your behalf when you favorite a Twitter URL. Quill will never post anything to your accounts without an explicit action on your part.

diff --git a/views/settings.php b/views/settings.php index 831528d..46df0bf 100644 --- a/views/settings.php +++ b/views/settings.php @@ -4,68 +4,16 @@

Signed In As

- +

Access Token

+

Twitter

+

Connecting a Twitter account will automatically "favorite" tweets on Twitter when you favorite a Twitter URL in Quill.

-

Instagram

- -