OAuthOAuth2ServiceFoursquare

The Gravity Forms Salesforce Add-On OAuth OAuth2 Service Foursquare class.

Defined (1)

The class is defined in the following location(s).

/lib/PHPoAuthLib/src/OAuth/OAuth2/Service/Foursquare.php  
  1. class Foursquare extends AbstractService 
  2. private $apiVersionDate = '20130829'; 
  3.  
  4. public function __construct( 
  5. CredentialsInterface $credentials,  
  6. ClientInterface $httpClient,  
  7. TokenStorageInterface $storage,  
  8. $scopes = array(),  
  9. UriInterface $baseApiUri = null 
  10. ) { 
  11. parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); 
  12.  
  13. if (null === $baseApiUri) { 
  14. $this->baseApiUri = new Uri('https://api.foursquare.com/v2/'); 
  15.  
  16. /** 
  17. * {@inheritdoc} 
  18. */ 
  19. public function getAuthorizationEndpoint() 
  20. return new Uri('https://foursquare.com/oauth2/authenticate'); 
  21.  
  22. /** 
  23. * {@inheritdoc} 
  24. */ 
  25. public function getAccessTokenEndpoint() 
  26. return new Uri('https://foursquare.com/oauth2/access_token'); 
  27.  
  28. /** 
  29. * {@inheritdoc} 
  30. */ 
  31. protected function parseAccessTokenResponse($responseBody) 
  32. $data = json_decode($responseBody, true); 
  33.  
  34. if (null === $data || !is_array($data)) { 
  35. throw new TokenResponseException('Unable to parse response.'); 
  36. } elseif (isset($data['error'])) { 
  37. throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); 
  38.  
  39. $token = new StdOAuth2Token(); 
  40. $token->setAccessToken($data['access_token']); 
  41. // Foursquare tokens evidently never expire... 
  42. $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); 
  43. unset($data['access_token']); 
  44.  
  45. $token->setExtraParams($data); 
  46.  
  47. return $token; 
  48.  
  49. /** 
  50. * {@inheritdoc} 
  51. */ 
  52. public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) 
  53. $uri = new Uri($this->baseApiUri . $path); 
  54. $uri->addToQuery('v', $this->apiVersionDate); 
  55.  
  56. return parent::request($uri, $method, $body, $extraHeaders);