Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 9b97ba0

Browse files
committed
:octocat: changed parameter order of OAuth1Client::requestHeaders()
1 parent 5205c5d commit 9b97ba0

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Core/OAuth1Provider.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,20 +212,20 @@ public function getAccessToken(string $token, string $verifier, string $tokenSec
212212
* @return array
213213
*/
214214
protected function getAccessTokenHeaders(array $body):array {
215-
return $this->requestHeaders($this->accessTokenURL, $body, 'POST', [], $this->storage->getAccessToken($this->serviceName));
215+
return $this->requestHeaders($this->storage->getAccessToken($this->serviceName), $this->accessTokenURL, 'POST', $body, []);
216216
}
217217

218218
/**
219+
* @param \chillerlan\OAuth\Core\AccessToken $token
219220
* @param string $url
220-
* @param array|string $params
221221
* @param string $method
222+
* @param array|string $params
222223
* @param array $headers
223-
* @param \chillerlan\OAuth\Core\AccessToken $token
224224
*
225225
* @return array
226226
* @throws \Exception
227227
*/
228-
protected function requestHeaders(string $url, $params = null, string $method, array $headers = null, AccessToken $token):array{
228+
protected function requestHeaders(AccessToken $token, string $url, string $method, $params = null, array $headers = null):array{
229229
$this->tokenSecret = $token->accessTokenSecret;
230230
$parameters = $this->requestHeaderParams($token);
231231

@@ -252,7 +252,7 @@ protected function requestHeaderParams(AccessToken $token):array {
252252
'oauth_consumer_key' => $this->options->key,
253253
'oauth_nonce' => $this->nonce(),
254254
'oauth_signature_method' => 'HMAC-SHA1',
255-
'oauth_timestamp' => (new DateTime())->format('U'),
255+
'oauth_timestamp' => (new DateTime)->format('U'),
256256
'oauth_token' => $token->accessToken,
257257
'oauth_version' => '1.0',
258258
];
@@ -271,11 +271,11 @@ public function request(string $path, array $params = null, string $method = nul
271271
$method = $method ?? 'GET';
272272

273273
$headers = $this->requestHeaders(
274+
$this->storage->getAccessToken($this->serviceName),
274275
$this->apiURL.$path,
275-
$body ?? $params,
276276
$method,
277-
$headers,
278-
$this->storage->getAccessToken($this->serviceName)
277+
$body ?? $params,
278+
$headers
279279
);
280280

281281
return $this->httpRequest($this->apiURL.$path, $params, $method, $body, $headers);

tests/Core/OAuth1Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function testGetRequestTokenHeaderParams(){
111111
public function testRequestHeaders(){
112112
$headers = $this
113113
->getMethod('requestHeaders')
114-
->invokeArgs($this->provider, ['http://localhost/api/whatever', ['oauth_session_handle' => 'nope'], 'GET', [], new AccessToken(['accessTokenSecret' => 'test_token_secret', 'accessToken' => 'test_token'])]);
114+
->invokeArgs($this->provider, [new AccessToken(['accessTokenSecret' => 'test_token_secret', 'accessToken' => 'test_token']), 'http://localhost/api/whatever', 'GET', ['oauth_session_handle' => 'nope'], []]);
115115

116116
$this->assertContains('OAuth oauth_consumer_key="'.$this->options->key.'", oauth_nonce="', $headers['Authorization']);
117117
}

0 commit comments

Comments
 (0)