OAuthOAuth1ServiceFlickr

The Gravity Forms Salesforce Add-On OAuth OAuth1 Service Flickr class.

Defined (1)

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

/lib/PHPoAuthLib/src/OAuth/OAuth1/Service/Flickr.php  
  1. class Flickr extends AbstractService 
  2.  
  3. public function __construct( 
  4. CredentialsInterface $credentials,  
  5. ClientInterface $httpClient,  
  6. TokenStorageInterface $storage,  
  7. SignatureInterface $signature,  
  8. UriInterface $baseApiUri = null 
  9. ) { 
  10. parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri); 
  11. if ($baseApiUri === null) { 
  12. $this->baseApiUri = new Uri('https://api.flickr.com/services/rest/'); 
  13.  
  14. public function getRequestTokenEndpoint() 
  15. return new Uri('https://www.flickr.com/services/oauth/request_token'); 
  16.  
  17. public function getAuthorizationEndpoint() 
  18. return new Uri('https://www.flickr.com/services/oauth/authorize'); 
  19.  
  20. public function getAccessTokenEndpoint() 
  21. return new Uri('https://www.flickr.com/services/oauth/access_token'); 
  22.  
  23. protected function parseRequestTokenResponse($responseBody) 
  24. parse_str($responseBody, $data); 
  25. if (null === $data || !is_array($data)) { 
  26. throw new TokenResponseException('Unable to parse response.'); 
  27. } elseif (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] != 'true') { 
  28. throw new TokenResponseException('Error in retrieving token.'); 
  29. return $this->parseAccessTokenResponse($responseBody); 
  30.  
  31. protected function parseAccessTokenResponse($responseBody) 
  32. parse_str($responseBody, $data); 
  33. if ($data === null || !is_array($data)) { 
  34. throw new TokenResponseException('Unable to parse response.'); 
  35. } elseif (isset($data['error'])) { 
  36. throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); 
  37.  
  38. $token = new StdOAuth1Token(); 
  39. $token->setRequestToken($data['oauth_token']); 
  40. $token->setRequestTokenSecret($data['oauth_token_secret']); 
  41. $token->setAccessToken($data['oauth_token']); 
  42. $token->setAccessTokenSecret($data['oauth_token_secret']); 
  43. $token->setEndOfLife(StdOAuth1Token::EOL_NEVER_EXPIRES); 
  44. unset($data['oauth_token'], $data['oauth_token_secret']); 
  45. $token->setExtraParams($data); 
  46.  
  47. return $token; 
  48.  
  49. public function request($path, $method = 'GET', $body = null, array $extraHeaders = array()) 
  50. $uri = $this->determineRequestUriFromPath('/', $this->baseApiUri); 
  51. $uri->addToQuery('method', $path); 
  52.  
  53. $token = $this->storage->retrieveAccessToken($this->service()); 
  54. $extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders); 
  55. $authorizationHeader = array( 
  56. 'Authorization' => $this->buildAuthorizationHeaderForAPIRequest($method, $uri, $token, $body) 
  57. ); 
  58. $headers = array_merge($authorizationHeader, $extraHeaders); 
  59.  
  60. return $this->httpClient->retrieveResponse($uri, $body, $headers, $method);