Blame view

src/lib/socialAuth/OAuth/socialAuthOAuth10Twitter.class.php 3.03 KB
1ea3b987   Administrator   maby first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  <?php
  
  /**
   * socialAuthOAuth10Twitter Class
   *
   * @author		Roman
   * @version         1.0.20111010
   */
  class socialAuthOAuth10Twitter extends socialAuthOAuth10
  {
      ///////////////////////////////////////////////////////////////////////////
  
      public function __construct( $settings )
      {
          $this->settings = $settings;
      }
      
      ///////////////////////////////////////////////////////////////////////////
  
      // inherits: init()
      // inherits: requestToken()
      // inherits: authorize()
      // inherits: accessToken()
      // inherits: fetchProfileInfo()
      // inherits: getProfileInfo()
  
      ///////////////////////////////////////////////////////////////////////////    
  
      protected function getProfileInfo( $data = array() )
      {   
          if( empty($data) )
          {
              return false;
          }
      
          $user = array(
              'id'        => $data['id'],
              'login'     => ( isset($data['screen_name']) ? $data['screen_name'] : 'id'.$data['id'] ),
              'email'     => ( isset($data['screen_name']) ? $data['screen_name'] : 'id'.$data['id'] ).'@twitter.com',
              'name'      => ( isset($data['name']) ? $data['name'] : ( strlen($data['screen_name'])>0 ? $data['screen_name'] : 'id'.$data['id'] ) ),
              );
          
          return 
              socialAuth::userLoginOrRegisterIfNotExists( 
                  array(
                      'login'         => 'twitter__'.$user['login'],
                      'email'         => $user['email'],
                      'name'          => $user['name'],
                      'bithday'       => null,
                      'gender'        => null,
                      'region_id'     => null,
                      'about_me'      => ( isset($data['description']) ? $data['description'] : null ),
                      'interests'     => null,
                      'vote'          => null,
                      'contact_icq'   => null,
                      'options'       => etc::arr2hstore( 
                                              array( 
                                                  'is_social'     => 1,
                                                  'id'            => $user['id'],
                                                  'login'         => $user['login'],
                                                  'name'          => $user['name'],    
                                                  'location'      => ( isset($data['location']) ? $data['location'] : '' ),
                                                  'lang'          => ( isset($data['lang']) ? $data['lang'] : '' ),
                                                  'timezone'      => ( isset($data['time_zone']) ? $data['time_zone'] : '' ),
                                                  'utc_offset'    => ( isset($data['utc_offset']) ? $data['utc_offset'] : '' ),
                                                  ) 
                                              ),
                      )                     
                  );
      }
  
      ///////////////////////////////////////////////////////////////////////////    
  }