Required parameters
return [ 'oauth_consumer_key' => $this->getCredential('oauth_consumer_key'), 'oauth_nonce' => $this->getNonce(), 'oauth_signature_method' => self::SIGNATURE_METHOD, 'oauth_timestamp' => time(), 'oauth_version' => self::VERSION, ];
If you have oauth_callback it would be included
$parameters = array_merge(['oauth_callback' => $callback], $this->getOauthParameters());
Then now you are ready
- ParametersString is combined by encode key & value with “=” at middle.
- Base string is combined {METHOD}&encode{URI}&encode{ParametersString}
- Key is encode($consumerSecret) ‘&’ encode(TokenSecret) ( if exists )
ksort($parameters); $parametersString = []; foreach ($parameters as $key => $value) { $parametersString[] = $this->encode($key) . '=' . $this->encode($value); } $baseSignature = strtoupper($method) . '&' . $this->encode($uri) . '&' . $this->encode(implode('&', $parametersString)); return $this->encode(base64_encode(hash_hmac('SHA1', $baseSignature, $this->getKey(), true)));
Leave a Reply