]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Use "Sign in with Twitter" auth pattern and official Twitter button for Twitter-based...
authorZach Copley <zach@status.net>
Tue, 26 Jan 2010 02:40:44 +0000 (02:40 +0000)
committerZach Copley <zach@status.net>
Tue, 26 Jan 2010 08:41:49 +0000 (00:41 -0800)
See: http://apiwiki.twitter.com/Sign-in-with-Twitter

plugins/TwitterBridge/twitter_connect.gif [deleted file]
plugins/TwitterBridge/twitterauthorization.php
plugins/TwitterBridge/twitterlogin.php
plugins/TwitterBridge/twitteroauthclient.php

diff --git a/plugins/TwitterBridge/twitter_connect.gif b/plugins/TwitterBridge/twitter_connect.gif
deleted file mode 100644 (file)
index e3d8f3e..0000000
Binary files a/plugins/TwitterBridge/twitter_connect.gif and /dev/null differ
index 3f7316b7a40f2087e97cedf10fd65c312e665195..15408668fc7d4a8350b219e0288e1db60a63c484 100644 (file)
@@ -50,9 +50,10 @@ require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
  */
 class TwitterauthorizationAction extends Action
 {
-    var $twuid = null;
-    var $tw_fields  = null;
+    var $twuid        = null;
+    var $tw_fields    = null;
     var $access_token = null;
+    var $signin       = null;
 
     /**
      * Initialize class members. Looks for 'oauth_token' parameter.
@@ -65,6 +66,7 @@ class TwitterauthorizationAction extends Action
     {
         parent::prepare($args);
 
+        $this->signin      = $this->boolean('signin');
         $this->oauth_token = $this->arg('oauth_token');
 
         return true;
@@ -160,7 +162,7 @@ class TwitterauthorizationAction extends Action
             $_SESSION['twitter_request_token']        = $req_tok->key;
             $_SESSION['twitter_request_token_secret'] = $req_tok->secret;
 
-            $auth_link = $client->getAuthorizeLink($req_tok);
+            $auth_link = $client->getAuthorizeLink($req_tok, $this->signin);
 
         } catch (OAuthClientException $e) {
             $msg = sprintf('OAuth client cURL error - code: %1s, msg: %2s',
index ae468ea15c2192d38569b82cbe755620ccbd8412..ae67b4c1549ae359d3872d69662879fbb47860a2 100644 (file)
@@ -46,7 +46,6 @@ require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
  * @see      SettingsAction
  */
 
-
 class TwitterloginAction extends Action
 {
     function handle($args)
@@ -67,7 +66,7 @@ class TwitterloginAction extends Action
 
     function getInstructions()
     {
-        return _('Login with your Twitter Account');
+        return _('Login with your Twitter account');
     }
 
     function showPageNotice()
@@ -81,9 +80,11 @@ class TwitterloginAction extends Action
 
     function showContent()
     {
-        $this->elementStart('a', array('href' => common_local_url('twitterauthorization')));
-        $this->element('img', array('src' => common_path('plugins/TwitterBridge/twitter_connect.gif'),
-                                    'alt' => 'Connect my Twitter account'));
+        $this->elementStart('a', array('href' => common_local_url('twitterauthorization',
+                                                                  null,
+                                                                  array('signin' => true))));
+        $this->element('img', array('src' => common_path('plugins/TwitterBridge/Sign-in-with-Twitter-lighter.png'),
+                                    'alt' => 'Sign in with Twitter'));
         $this->elementEnd('a');
     }
 
index bad2b74ca324101388eaa6feae1e787e65c72892..277e7ab409c69b76598e5a72a093274f263c3d49 100644 (file)
@@ -45,6 +45,7 @@ class TwitterOAuthClient extends OAuthClient
 {
     public static $requestTokenURL = 'https://twitter.com/oauth/request_token';
     public static $authorizeURL    = 'https://twitter.com/oauth/authorize';
+    public static $signinUrl       = 'https://twitter.com/oauth/authenticate';
     public static $accessTokenURL  = 'https://twitter.com/oauth/access_token';
 
     /**
@@ -97,9 +98,11 @@ class TwitterOAuthClient extends OAuthClient
      *
      * @return the link
      */
-    function getAuthorizeLink($request_token)
+    function getAuthorizeLink($request_token, $signin = false)
     {
-        return parent::getAuthorizeLink(self::$authorizeURL,
+        $url = ($signin) ? self::$signinUrl : self::$authorizeURL;
+
+        return parent::getAuthorizeLink($url,
                                         $request_token,
                                         common_local_url('twitterauthorization'));
     }