diff options
author | Aaron Parecki <aaron@parecki.com> | 2016-12-19 10:39:23 -0800 |
---|---|---|
committer | Aaron Parecki <aaron@parecki.com> | 2016-12-19 10:39:23 -0800 |
commit | 4aa06023f0c25a10d5eaeafaeb30034e0a4f2e95 (patch) | |
tree | e4a694fad5254166d01934aed9f344fc2903a2df /controllers/auth.php | |
parent | 53964f2622828bc5b67546dbc24bb455e4d165cb (diff) |
clean up note UI, show reply context
* shows reply context of the URL you're replying to
* autocomplete nicknames from the post when replying
* moved debug info to the settings screen to clean up the UI
Diffstat (limited to 'controllers/auth.php')
-rw-r--r-- | controllers/auth.php | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/controllers/auth.php b/controllers/auth.php index fb8b6da..baf5c2f 100644 --- a/controllers/auth.php +++ b/controllers/auth.php @@ -1,4 +1,5 @@ <?php +use Abraham\TwitterOAuth\TwitterOAuth; function buildRedirectURI() { return Config::$base_url . 'auth/callback'; @@ -260,9 +261,11 @@ $app->post('/auth/twitter', function() use($app) { }); function getTwitterLoginURL(&$twitter) { - $request_token = $twitter->getRequestToken(Config::$base_url . 'auth/twitter/callback'); + $request_token = $twitter->oauth('oauth/request_token', [ + 'oauth_callback' => Config::$base_url . 'auth/twitter/callback' + ]); $_SESSION['twitter_auth'] = $request_token; - return $twitter->getAuthorizeURL($request_token['oauth_token']); + return $twitter->url('oauth/authorize', ['oauth_token' => $request_token['oauth_token']]); } $app->get('/auth/twitter', function() use($app) { @@ -272,15 +275,16 @@ $app->get('/auth/twitter', function() use($app) { // If there is an existing Twitter token, check if it is valid // Otherwise, generate a Twitter login link $twitter_login_url = false; - $twitter = new \TwitterOAuth\Api(Config::$twitterClientID, Config::$twitterClientSecret, - $user->twitter_access_token, $user->twitter_token_secret); if(array_key_exists('login', $params)) { - $twitter = new \TwitterOAuth\Api(Config::$twitterClientID, Config::$twitterClientSecret); + $twitter = new TwitterOAuth(Config::$twitterClientID, Config::$twitterClientSecret); $twitter_login_url = getTwitterLoginURL($twitter); } else { + $twitter = new TwitterOAuth(Config::$twitterClientID, Config::$twitterClientSecret, + $user->twitter_access_token, $user->twitter_token_secret); + if($user->twitter_access_token) { - if ($twitter->get('account/verify_credentials')) { + if($twitter->get('account/verify_credentials')) { $app->response()['Content-type'] = 'application/json'; $app->response()->body(json_encode(array( 'result' => 'ok' @@ -312,9 +316,9 @@ $app->get('/auth/twitter/callback', function() use($app) { if($user=require_login($app)) { $params = $app->request()->params(); - $twitter = new \TwitterOAuth\Api(Config::$twitterClientID, Config::$twitterClientSecret, + $twitter = new TwitterOAuth(Config::$twitterClientID, Config::$twitterClientSecret, $_SESSION['twitter_auth']['oauth_token'], $_SESSION['twitter_auth']['oauth_token_secret']); - $credentials = $twitter->getAccessToken($params['oauth_verifier']); + $credentials = $twitter->oauth('oauth/access_token', ['oauth_verifier' => $params['oauth_verifier']]); $user->twitter_access_token = $credentials['oauth_token']; $user->twitter_token_secret = $credentials['oauth_token_secret']; |