public function OAuthSignatureMethod_HMAC::build_signature in OAuth 1.0 7.3
Same name and namespace in other branches
- 6.3 includes/OAuthSignatureMethod_HMAC.inc \OAuthSignatureMethod_HMAC::build_signature()
- 7.4 includes/OAuthSignatureMethod_HMAC.inc \OAuthSignatureMethod_HMAC::build_signature()
Build up the signature NOTE: The output of this function MUST NOT be urlencoded. the encoding is handled in OAuthRequest when the final request is serialized
Parameters
OAuthRequest $request:
OAuthConsumer $consumer:
OAuthToken $token:
Return value
string
Overrides OAuthSignatureMethod::build_signature
File
- includes/
OAuthSignatureMethod_HMAC.inc, line 51
Class
- OAuthSignatureMethod_HMAC
- A generic signature method implementation that leverages hash_hmac() for increased flexibility.
Code
public function build_signature($request, $consumer, $token) {
$base_string = $request
->get_signature_base_string();
$request->base_string = $base_string;
$key_parts = array(
$consumer->secret,
$token ? $token->secret : "",
);
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
$key = implode('&', $key_parts);
return base64_encode(hash_hmac($this->algo, $base_string, $key, TRUE));
}