Skip to content
This repository was archived by the owner on Jul 19, 2022. It is now read-only.

Commit a6801ba

Browse files
Merge pull request #13 from sznowak/master
fix generation oauth signature base
2 parents 7772e1f + 40a61f0 commit a6801ba

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Client.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,17 @@ protected function sign($method, $url, $params = []) {
110110
'oauth_timestamp' => time(),
111111
'oauth_version' => '1.0'
112112
], $params);
113+
114+
// set query parameters
115+
$parsedQuery = [];
116+
parse_str($parsedURL['query'], $parsedQuery);
117+
$params = array_merge($parsedQuery, $params);
118+
119+
//sort parameters by key
113120
ksort($params);
114121

115122
// generate string to be signed
116-
$string = $method . '&' . rawurlencode($url) . '&' . rawurlencode(http_build_query($params) . (isset($parsedURL['query']) ? '&' . $parsedURL['query'] : ''));
123+
$string = $method . '&' . rawurlencode($url) . '&' . rawurlencode(http_build_query($params, null, '&', PHP_QUERY_RFC3986));
117124

118125
// calculate signature
119126
$params['oauth_signature'] = base64_encode(hash_hmac('sha1', $string, rawurlencode(self::$consumer_secret) . '&' . rawurlencode(self::$oauth_token_secret), true));

0 commit comments

Comments
 (0)