1 | <?php |
||
18 | class Buffer extends AbstractService |
||
19 | { |
||
20 | public function __construct( |
||
21 | CredentialsInterface $credentials, |
||
22 | ClientInterface $httpClient, |
||
23 | TokenStorageInterface $storage, |
||
24 | $scopes = array(), |
||
25 | UriInterface $baseApiUri = null |
||
26 | ) { |
||
27 | parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); |
||
28 | if ($baseApiUri === null) { |
||
29 | $this->baseApiUri = new Uri('https://api.bufferapp.com/1/'); |
||
30 | } |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * {@inheritdoc} |
||
35 | */ |
||
36 | public function getAuthorizationEndpoint() |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | public function getAccessTokenEndpoint() |
||
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | protected function getAuthorizationMethod() |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function getAuthorizationUri(array $additionalParameters = array()) |
||
61 | { |
||
62 | $parameters = array_merge( |
||
63 | $additionalParameters, |
||
64 | array( |
||
65 | 'client_id' => $this->credentials->getConsumerId(), |
||
66 | 'redirect_uri' => $this->credentials->getCallbackUrl(), |
||
67 | 'response_type' => 'code', |
||
68 | ) |
||
69 | ); |
||
70 | |||
71 | // Build the url |
||
72 | $url = clone $this->getAuthorizationEndpoint(); |
||
73 | foreach ($parameters as $key => $val) { |
||
74 | $url->addToQuery($key, $val); |
||
75 | } |
||
76 | |||
77 | return $url; |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | */ |
||
83 | public function requestRequestToken() |
||
84 | { |
||
85 | $responseBody = $this->httpClient->retrieveResponse( |
||
86 | $this->getRequestTokenEndpoint(), |
||
|
|||
87 | array( |
||
88 | 'client_key' => $this->credentials->getConsumerId(), |
||
89 | 'redirect_uri' => $this->credentials->getCallbackUrl(), |
||
90 | 'response_type' => 'code', |
||
91 | ) |
||
92 | ); |
||
93 | |||
94 | $code = $this->parseRequestTokenResponse($responseBody); |
||
95 | |||
96 | return $code; |
||
97 | } |
||
98 | |||
99 | protected function parseRequestTokenResponse($responseBody) |
||
110 | |||
111 | public function requestAccessToken($code) |
||
112 | { |
||
113 | $bodyParams = array( |
||
114 | 'client_id' => $this->credentials->getConsumerId(), |
||
115 | 'client_secret' => $this->credentials->getConsumerSecret(), |
||
116 | 'redirect_uri' => $this->credentials->getCallbackUrl(), |
||
117 | 'code' => $code, |
||
118 | 'grant_type' => 'authorization_code', |
||
119 | ); |
||
120 | |||
121 | $responseBody = $this->httpClient->retrieveResponse( |
||
122 | $this->getAccessTokenEndpoint(), |
||
123 | $bodyParams, |
||
124 | $this->getExtraOAuthHeaders() |
||
125 | ); |
||
126 | $token = $this->parseAccessTokenResponse($responseBody); |
||
127 | $this->storage->storeAccessToken($this->service(), $token); |
||
128 | |||
129 | return $token; |
||
130 | } |
||
131 | |||
132 | protected function parseAccessTokenResponse($responseBody) |
||
151 | } |
||
152 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.