diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65c872d..e017efb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] + php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] steps: - name: Checkout diff --git a/src/OAuth1.php b/src/OAuth1.php index 8074c6c..1b79de4 100644 --- a/src/OAuth1.php +++ b/src/OAuth1.php @@ -335,6 +335,8 @@ public function signRequest($request, $token = null) */ protected function composeSignatureBaseString($method, $url, array $params) { + $url = isset($url) ? $url : ''; + if (strpos($url, '?') !== false) { list($url, $queryString) = explode('?', $url, 2); parse_str($queryString, $urlParams); @@ -342,6 +344,9 @@ protected function composeSignatureBaseString($method, $url, array $params) } unset($params['oauth_signature']); uksort($params, 'strcmp'); // Parameters are sorted by name, using lexicographical byte value ordering. Ref: Spec: 9.1.1 + + $method = isset($method) ? $method : ''; + $parts = [ strtoupper($method), $url, @@ -359,15 +364,17 @@ protected function composeSignatureBaseString($method, $url, array $params) */ protected function composeSignatureKey($token = null) { + $signatureKeyParts = [ - $this->consumerSecret + isset($this->consumerSecret) ? $this->consumerSecret : '' ]; if ($token === null) { $token = $this->getAccessToken(); } if (is_object($token)) { - $signatureKeyParts[] = $token->getTokenSecret(); + $ts = $token->getTokenSecret(); + $signatureKeyParts[] = isset($ts)? $ts: ''; } else { $signatureKeyParts[] = ''; }