1 | <?php |
||
9 | class Instagram extends AbstractProvider |
||
10 | { |
||
11 | /** |
||
12 | * @var string Key used in a token response to identify the resource owner. |
||
13 | */ |
||
14 | const ACCESS_TOKEN_RESOURCE_OWNER_ID = 'user.id'; |
||
15 | |||
16 | /** |
||
17 | * Default scopes |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | public $defaultScopes = ['basic']; |
||
22 | |||
23 | /** |
||
24 | * Get the string used to separate scopes. |
||
25 | * |
||
26 | * @return string |
||
27 | */ |
||
28 | 6 | protected function getScopeSeparator() |
|
32 | |||
33 | /** |
||
34 | * Get authorization url to begin OAuth flow |
||
35 | * |
||
36 | * @return string |
||
37 | */ |
||
38 | 6 | public function getBaseAuthorizationUrl() |
|
42 | |||
43 | /** |
||
44 | * Get access token url to retrieve token |
||
45 | * |
||
46 | * @param array $params |
||
47 | * |
||
48 | * @return string |
||
49 | */ |
||
50 | 12 | public function getBaseAccessTokenUrl(array $params) |
|
54 | |||
55 | /** |
||
56 | * Get provider url to fetch user details |
||
57 | * |
||
58 | * @param AccessToken $token |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | 2 | public function getResourceOwnerDetailsUrl(AccessToken $token) |
|
66 | |||
67 | /** |
||
68 | * Returns an authenticated PSR-7 request instance. |
||
69 | * |
||
70 | * @param string $method |
||
71 | * @param string $url |
||
72 | * @param AccessToken|string $token |
||
73 | * @param array $options Any of "headers", "body", and "protocolVersion". |
||
74 | * |
||
75 | * @return \Psr\Http\Message\RequestInterface |
||
76 | */ |
||
77 | 4 | public function getAuthenticatedRequest($method, $url, $token, array $options = []) |
|
78 | { |
||
79 | 4 | $parsedUrl = parse_url($url); |
|
80 | 4 | $queryString = array(); |
|
81 | |||
82 | 4 | if (isset($parsedUrl['query'])) { |
|
83 | 2 | parse_str($parsedUrl['query'], $queryString); |
|
84 | 2 | } |
|
85 | |||
86 | 4 | if (!isset($queryString['access_token'])) { |
|
87 | 2 | $queryString['access_token'] = (string) $token; |
|
88 | 2 | } |
|
89 | |||
90 | 4 | $url = http_build_url($url, [ |
|
91 | 4 | 'query' => http_build_query($queryString), |
|
92 | 4 | ]); |
|
93 | |||
94 | 4 | return $this->createRequest($method, $url, null, $options); |
|
95 | } |
||
96 | |||
97 | /** |
||
98 | * Get the default scopes used by this provider. |
||
99 | * |
||
100 | * This should not be a complete list of all scopes, but the minimum |
||
101 | * required for the provider user interface! |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | 4 | protected function getDefaultScopes() |
|
109 | |||
110 | /** |
||
111 | * Check a provider response for errors. |
||
112 | * |
||
113 | * @link https://instagram.com/developer/endpoints/ |
||
114 | * @throws IdentityProviderException |
||
115 | * @param ResponseInterface $response |
||
116 | * @param string $data Parsed response data |
||
117 | * @return void |
||
118 | */ |
||
119 | 10 | protected function checkResponse(ResponseInterface $response, $data) |
|
131 | |||
132 | /** |
||
133 | * Generate a user object from a successful user details request. |
||
134 | * |
||
135 | * @param array $response |
||
136 | * @param AccessToken $token |
||
137 | * @return ResourceOwnerInterface |
||
138 | */ |
||
139 | 2 | protected function createResourceOwner(array $response, AccessToken $token) |
|
143 | } |
||
144 |