Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 56 lines (47 sloc) 1.761 kb
7081182 @Nodge Initial commit.
authored
1 <?php
2 /**
3 * TwitterOAuthService class file.
4 *
6b5fbbf @Nodge * Added access_token lifetime handling, #1 closed. Please, check your cu...
authored
5 * Register application: https://dev.twitter.com/apps/new
6 *
7081182 @Nodge Initial commit.
authored
7 * @author Maxim Zemskov <nodge@yandex.ru>
86efaf4 @Nodge Update links to the project.
authored
8 * @link http://github.com/Nodge/yii-eauth/
7081182 @Nodge Initial commit.
authored
9 * @license http://www.opensource.org/licenses/bsd-license.php
10 */
11
12 require_once dirname(dirname(__FILE__)).'/EOAuthService.php';
13
14 /**
15 * Twitter provider class.
16 * @package application.extensions.eauth.services
17 */
18 class TwitterOAuthService extends EOAuthService {
19
20 protected $name = 'twitter';
21 protected $title = 'Twitter';
22 protected $type = 'OAuth';
23 protected $jsArguments = array('popup' => array('width' => 900, 'height' => 550));
24
25 protected $key = '';
26 protected $secret = '';
27 protected $providerOptions = array(
28 'request' => 'https://api.twitter.com/oauth/request_token',
4965826 @Nodge Fixed issue #11. Twitter must authorize user everytime they login.
authored
29 'authorize' => 'https://api.twitter.com/oauth/authenticate', //https://api.twitter.com/oauth/authorize
7081182 @Nodge Initial commit.
authored
30 'access' => 'https://api.twitter.com/oauth/access_token',
31 );
32
33 protected function fetchAttributes() {
34 $info = $this->makeSignedRequest('https://api.twitter.com/1/account/verify_credentials.json');
35
36 $this->attributes['id'] = $info->id;
37 $this->attributes['name'] = $info->name;
38 $this->attributes['url'] = 'http://twitter.com/account/redirect_by_id?id='.$info->id_str;
39
40 /*$this->attributes['username'] = $info->screen_name;
41 $this->attributes['language'] = $info->lang;
42 $this->attributes['timezone'] = timezone_name_from_abbr('', $info->utc_offset, date('I'));
43 $this->attributes['photo'] = $info->profile_image_url;*/
44 }
7d6b998 @Nodge Added handling for denied callback in the TwitterOAuthService.
authored
45
46 /**
47 * Authenticate the user.
48 * @return boolean whether user was successfuly authenticated.
49 */
50 public function authenticate() {
51 if (isset($_GET['denied']))
52 $this->cancel();
53
54 return parent::authenticate();
55 }
7081182 @Nodge Initial commit.
authored
56 }
Something went wrong with that request. Please try again.