Example #1
0
 /**
  * Generate a signed hash of the base string using the consumer and token
  * as the signing key.
  *
  *     $sig = $signature->sign($request, $consumer, $token);
  *
  * [!!] This method implements [OAuth 1.0 Spec 9.2.1](http://oauth.net/core/1.0/#rfc.section.9.2.1).
  *
  * @param   Request   request
  * @param   Consumer  consumer
  * @param   Token     token
  * @return string
  * @uses    Signature::key
  * @uses    Request::base_string
  */
 public function sign(Request $request, Consumer $consumer, Token $token = null)
 {
     // Get the signing key
     $key = $this->key($consumer, $token);
     // Get the base string for the signature
     $base_string = $request->baseString();
     // Sign the base string using the key
     return base64_encode(hash_hmac('sha1', $base_string, $key, true));
 }