Development

Changeset 21323

You must first sign up to be able to contribute.

Changeset 21323

Show
Ignore:
Timestamp:
08/22/09 01:41:39 (4 years ago)
Author:
dwhittle
Message:

ysfOpenPlugin [trunk]: added oauth clients for google, twitter, + tweaked yahoo client

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/ysfOpenPlugin/trunk/lib/oauth/ysfGoogleOAuthClient.class.php

    r20251 r21323  
    1717{ 
    1818  /** 
    19    * Initializes this ysfOAuthGoogleUser
     19   * Initializes this ysfGoogleOAuthClient
    2020   * 
    2121   * Available options: 
     
    2323   *  * oauth_request_token_api:         The oauth api endpoint for getting request tokens. 
    2424   *  * oauth_authorize_token_api:       The oauth api endpoint for authorizing tokens. 
    25    *  * oauth_access_token_api:          The oauth api endpoint for getting access tokens.    
     25   *  * oauth_access_token_api:          The oauth api endpoint for getting access tokens. 
    2626   *  * oauth_consumer_key:              The oauth consumer key 
    2727   *  * oauth_consumer_secret:           The oauth consumer secret 
     
    4141      'oauth_authorize_token_api'        => 'https://www.google.com/accounts/OAuthAuthorizeToken', 
    4242      'oauth_access_token_api'           => 'https://www.google.com/accounts/OAuthGetAccessToken', 
     43      'oauth_token_info_api'             => 'https://www.google.com/accounts/AuthSubTokenInfo', 
    4344      'oauth_consumer_signature_method'  => OAUTH_SIG_METHOD_HMACSHA1, 
    4445      'oauth_consumer_auth_type'         => OAUTH_AUTH_TYPE_AUTHORIZATION, 
     46 
     47      // google scopes 
     48      'contacts_api'       => 'http://www.google.com/m8/feeds/', 
     49      'calendar_api'       => 'http://www.google.com/calendar/feeds/', 
     50      'blogger_api'        => 'http://www.blogger.com/feeds/', 
     51      'analytics_api'      => 'https://www.google.com/analytics/feeds/', 
     52      'base_api'           => 'http://www.google.com/base/feeds/', 
     53      'books_api'          => 'http://www.google.com/books/feeds/', 
     54      'docs_api'           => 'http://docs.google.com/feeds/', 
     55      'finance_api'        => 'http://finance.google.com/finance/feeds/', 
     56      'gmail_api'          => 'https://mail.google.com/mail/feed/atom', 
     57      'health_api'         => 'https://www.google.com/h9/feeds/', 
     58      'maps_api'           => 'http://maps.google.com/maps/feeds/', 
     59      'picasa_api'         => 'http://picasaweb.google.com/data/', 
     60      'opensocial_api'     => 'http://www-opensocial.googleusercontent.com/api/', 
     61      'spreadsheets_api'   => 'http://spreadsheets.google.com/feeds/', 
     62      'webmaster_api'      => 'http://www.google.com/webmasters/tools/feeds/', 
     63      'youtube_api'        => 'http://gdata.youtube.com', 
     64 
    4565    ), $options); 
    46          
     66 
    4767    parent::initialize($dispatcher, $consumer, $options); 
    4868  } 
    4969 
     70  public function getRequestToken(array $scopes = array()) 
     71  { 
     72    $apis = array(); 
     73    foreach($scopes as $scope) 
     74    { 
     75      $scope_api = $scope.'_api'; 
     76      if (isset($this->options[$scope_api])) 
     77      { 
     78        $apis = $this->options[$scope_api]; 
     79      } 
     80      else 
     81      { 
     82        throw new sfException(); 
     83      } 
     84    } 
     85 
     86    return $this->getConsumer()->getRequestToken(sprintf('%s?scope=%s', $this->options['oauth_request_token_api'], oauth_urlencode(implode(' ', $apis))), $callbackUrl); 
     87  } 
     88 
     89  public function getProfile() 
     90  { 
     91    if ($this->options['logging']) 
     92    { 
     93      $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Fetching yahoo user presence for guid: "%s"', $guid)))); 
     94    } 
     95 
     96    $this->getConsumer()->fetch(sprintf('%s/user/%s/presence/presence?format=json', $this->options['social_api'], oauth_urlencode($guid))); 
     97 
     98    return json_decode($this->getConsumer()->getLastResponse()); 
     99  } 
     100 
     101 
    50102/* 
    51103 
    52   $scopes = urlencode("http://www.google.com/calendar/feeds/") . "%20" . urlencode("http://www.blogger.com/feeds/"); 
    53   $arrayResp = $o->getRequestToken("https://www.google.com/accounts/OAuthGetRequestToken?scope={$scopes}"); 
    54104  $authorizeUrl = "https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token={$arrayResp["oauth_token"]}"; 
    55    
     105 
     106 
     107  # Google Base 
     108  # http://www.google.com/base/feeds/snippets 
     109  # http://www.google.com/base/feeds/items 
     110  # http://www.google.com/base/feeds/attributes 
     111  # http://www.google.com/base/feeds/itemtypes/<locale> 
     112  # 
     113  # Analytics 
     114  # https://www.google.com/analytics/feeds/accounts/default 
     115  # 
     116  # Book Search 
     117  # http://www.google.com/books/feeds/volumes/[<volume_ID>] 
     118  # http://www.google.com/books/feeds/p/<PARTNER_COBRAND_ID>/volumes 
     119  # http://www.google.com/books/feeds/users/me/collections/library/volumes 
     120  # http://www.google.com/books/feeds/users/me/volumes 
     121  # 
     122  # Blogger 
     123  # http://www.blogger.com/feeds/default/blogs 
     124  # http://www.blogger.com/feeds/<blogID>/posts/default 
     125  # http://www.blogger.com/feeds/<blogID>/[<postID>]/comments/default 
     126  # 
     127  # Calendar 
     128  # http://www.google.com/calendar/feeds/default/allcalendars/full/[<calendarID>] 
     129  # http://www.google.com/calendar/feeds/default/owncalendars/full 
     130  # http://www.google.com/calendar/feeds/default/<visibility>/full/[<eventID>] 
     131  # 
     132  # Contacts 
     133  # http://www.google.com/m8/feeds/contacts/default/full/[<contactID>] 
     134  # http://www.google.com/m8/feeds/groups/default/full/[<contactID>] 
     135  # 
     136  # Documents List 
     137  # http://docs.google.com/feeds/documents/private/full/ 
     138  # http://docs.google.com/feeds/acl/private/full/<resource_id> 
     139  # http://docs.google.com/feeds/folder/private/full/<folder_id> 
     140  # 
     141  # Finance 
     142  # http://finance.google.com/finance/feeds/default/portfolios/[<portfolioID>] 
     143  # http://finance.google.com/finance/feeds/default/portfolios/<portfolioID>/positions/[<tickerID>] 
     144  # http://finance.google.com/finance/feeds/default/portfolios/<portfolioID>/positions/<tickerID>/transactions/[<transactionID>] 
     145  # 
     146  # YouTube 
     147  # http://gdata.youtube.com/feeds/api/users/default 
     148  # http://gdata.youtube.com/feeds/api/users/default/contacts 
     149  # http://gdata.youtube.com/feeds/api/users/default/favorites 
     150  # http://gdata.youtube.com/feeds/api/users/default/playlists/[<playlistID>] 
     151  # http://gdata.youtube.com/feeds/api/users/default/subscriptions 
     152  # http://gdata.youtube.com/feeds/api/videos/<videoID>/related 
     153  # http://gdata.youtube.com/feeds/api/videos/<videoID>/responses 
     154  # http://gdata.youtube.com/feeds/api/videos/<videoID>/comments 
     155  # http://gdata.youtube.com/feeds/api/standardfeeds/[<regionID>]/top_rated 
     156  # http://gdata.youtube.com/feeds/api/standardfeeds/[<regionID>]/top_favorites 
     157  # http://gdata.youtube.com/feeds/api/standardfeeds/[<regionID>]/most_viewed 
     158  # http://gdata.youtube.com/feeds/api/standardfeeds/[<regionID>]/most_popular 
     159  # http://gdata.youtube.com/feeds/api/standardfeeds/[<regionID>]/most_recent 
     160  # http://gdata.youtube.com/feeds/api/standardfeeds/[<regionID>]/most_discussed 
     161  # http://gdata.youtube.com/feeds/api/standardfeeds/[<regionID>]/most_linked 
     162  # http://gdata.youtube.com/feeds/api/standardfeeds/[<regionID>]/most_responded 
     163  # http://gdata.youtube.com/feeds/api/standardfeeds/[<regionID>]/recently_featured 
     164  # http://gdata.youtube.com/feeds/api/standardfeeds/watch_on_mobile 
     165  # 
     166  # Spreadsheets 
     167  # http://spreadsheets.google.com/feeds/spreadsheets/private/full/[<key>] 
     168  # http://spreadsheets.google.com/feeds/worksheets/<key>/private/full/[<worksheetID>] 
     169  # http://spreadsheets.google.com/feeds/list/<key>/<worksheetID>/private/full/[<rowID>] 
     170  # http://spreadsheets.google.com/feeds/cells/<key>/<worksheetID>/private/full/[<cellID>] 
     171  # http://spreadsheets.google.com/feeds/<key>/tables/[<tableID>] 
     172  # http://spreadsheets.google.com/feeds/<key>/records/<tableID>/[<recordID>] 
     173  # 
     174  # Webmaster Tools 
     175  # http://www.google.com/webmasters/tools/feeds/sites/[<siteID>] 
     176  # http://www.google.com/webmasters/tools/feeds/<siteID>/sitemaps 
     177  # 
     178  # Picasa Web 
     179  # http://picasaweb.google.com/data/feed/api/user/default/[albumid/<albumID>] 
     180  # http://picasaweb.google.com/data/entry/api/user/default/albumid/<albumID>/<versionNumber> 
     181  # http://picasaweb.google.com/data/entry/api/user/default/albumid/<albumID>/photoid/<photoID>/<versionNumber> 
     182  # http://picasaweb.google.com/data/media/api/user/default/albumid/<albumID>/photoid/<photoID>/<versionNumber> 
     183  # 
     184  # Maps 
     185  # http://maps.google.com/maps/feeds/maps/default/full 
     186  # http://maps.google.com/maps/feeds/maps/userID/full/[<elementID>] 
     187  # http://maps.google.com/maps/feeds/features/default/[<mapID>]/full/[<elementID>] 
     188  # 
     189  # GMail 
     190  # https://mail.google.com/mail/feed/atom/[<label>] 
     191 
     192 
    56193  ->getProfile 
    57194  ->getContacts 
    58 */ 
    59195 
    60196} 
  • plugins/ysfOpenPlugin/trunk/lib/oauth/ysfYahooOAuthClient.class.php

    r20251 r21323  
    1717{ 
    1818  /** 
    19    * Initializes this ysfOAuthYahooUser
     19   * Initializes this ysfYahooOAuthClient
    2020   * 
    2121   * Available options: 
     
    4747      'yql_api'                         => 'http://query.yahooapis.com/v1/yql', 
    4848      'yql_public_api'                  => 'http://query.yahooapis.com/v1/public/yql', 
    49       'social_api'                      => 'http://social.yahooapis.com/v1', 
    50       'test_api'                        => 'http://json-service.appspot.com/echo', 
     49      'social_api'                      => 'http://social.yahooapis.com/v1' 
    5150    ), $options); 
    5251 
    5352    parent::initialize($dispatcher, $consumer, $options); 
    5453  } 
    55    
     54 
    5655  /** 
    5756   * YQL API 
     
    6463      $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Fetching yql: "%s"', $query)))); 
    6564    } 
    66      
     65 
    6766    $yql = ($public === false) ? $this->options['yql_api'] : $this->options['yql_public_api']; 
    6867 
     
    7271    return json_decode($this->getConsumer()->getLastResponse()); 
    7372  } 
    74    
    75    
     73 
     74 
    7675  /** 
    7776   * Social Directory API 
    7877   */ 
    79    
     78 
    8079  public function getPresence($guid) 
    8180  { 
     
    9089    return json_decode($this->getConsumer()->getLastResponse()); 
    9190  } 
    92    
    93    
     91 
     92 
    9493  public function setPresence($guid, $presence) 
    9594  { 
     
    104103    return json_decode($this->getConsumer()->getLastResponse()); 
    105104  } 
    106    
     105 
    107106  public function getProfile($guid) 
    108107  { 
     
    117116    return json_decode($this->getConsumer()->getLastResponse()); 
    118117  } 
    119    
     118 
    120119  public function getConnections($guid, $offset = 0, $limit = 100) 
    121120  { 
     
    125124    } 
    126125    $this->getConsumer()->setAuthType(OAUTH_AUTH_TYPE_AUTHORIZATION); 
    127      
     126 
    128127    $this->getConsumer()->fetch(sprintf('%s/user/%s/connections?format=json&view=usercard&start=%s&count=%d', $this->options['social_api'], oauth_urlencode($guid), $offset, $limit)); 
    129128    return json_decode($this->getConsumer()->getLastResponse()); 
    130129  } 
    131    
     130 
    132131  public function getContacts($guid, $offset = 0, $limit = 100) 
    133132  { 
     
    155154    return json_decode($this->getConsumer()->getLastResponse()); 
    156155  } 
    157    
     156 
    158157  public function getConnectionsUpdates($guid, $offset = 0, $limit = 100) 
    159158  {