/** * @param Request $request * @param Consumer $consumer * @param Token $token * @return string */ public function buildSignature(Request $request, Consumer $consumer, Token $token) { $signatureBase = $request->getSignatureBaseString(); $parts = array($consumer->getSecret(), null !== $token ? $token->getSecret() : ''); $parts = Util::urlencodeRFC3986($parts); $key = implode('&', $parts); return base64_encode(hash_hmac('sha1', $signatureBase, $key, true)); }
/** * builds the Authorization: header * @param mixed $realm * @return array */ public function toHeader($realm = null) { $first = true; if ($realm) { $out = 'OAuth realm="' . Util::urlencodeRFC3986($realm) . '"'; $first = false; } else { $out = 'OAuth'; } foreach ($this->parameters as $k => $v) { if (substr($k, 0, 5) != "oauth") { continue; } if (is_array($v)) { continue; } $out .= $first ? ' ' : ', '; $out .= Util::urlencodeRFC3986($k) . '="' . Util::urlencodeRFC3986($v) . '"'; $first = false; } return array('Authorization' => $out); //- hacked into this to make it return an array. 15/11/2014. }