OAuthOAuth2ServiceInstagram

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

Defined (1)

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

/lib/PHPoAuthLib/src/OAuth/OAuth2/Service/Instagram.php  
  1. class Instagram extends AbstractService 
  2. /** 
  3. * Defined scopes 
  4. * @link http://instagram.com/developer/authentication/#scope 
  5. */ 
  6. const SCOPE_BASIC = 'basic'; 
  7. const SCOPE_COMMENTS = 'comments'; 
  8. const SCOPE_RELATIONSHIPS = 'relationships'; 
  9. const SCOPE_LIKES = 'likes'; 
  10.  
  11. public function __construct( 
  12. CredentialsInterface $credentials,  
  13. ClientInterface $httpClient,  
  14. TokenStorageInterface $storage,  
  15. $scopes = array(),  
  16. UriInterface $baseApiUri = null 
  17. ) { 
  18. parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); 
  19.  
  20. if (null === $baseApiUri) { 
  21. $this->baseApiUri = new Uri('https://api.instagram.com/v1/'); 
  22.  
  23. /** 
  24. * {@inheritdoc} 
  25. */ 
  26. public function getAuthorizationEndpoint() 
  27. return new Uri('https://api.instagram.com/oauth/authorize/'); 
  28.  
  29. /** 
  30. * {@inheritdoc} 
  31. */ 
  32. public function getAccessTokenEndpoint() 
  33. return new Uri('https://api.instagram.com/oauth/access_token'); 
  34.  
  35. /** 
  36. * {@inheritdoc} 
  37. */ 
  38. protected function getAuthorizationMethod() 
  39. return static::AUTHORIZATION_METHOD_QUERY_STRING; 
  40.  
  41. /** 
  42. * {@inheritdoc} 
  43. */ 
  44. protected function parseAccessTokenResponse($responseBody) 
  45. $data = json_decode($responseBody, true); 
  46.  
  47. if (null === $data || !is_array($data)) { 
  48. throw new TokenResponseException('Unable to parse response.'); 
  49. } elseif (isset($data['error'])) { 
  50. throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); 
  51.  
  52. $token = new StdOAuth2Token(); 
  53. $token->setAccessToken($data['access_token']); 
  54. // Instagram tokens evidently never expire... 
  55. $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES); 
  56. unset($data['access_token']); 
  57.  
  58. $token->setExtraParams($data); 
  59.  
  60. return $token;