Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function signRequest(OAuthRequest $request, OAuth $oauth)
 {
     $request->setOAuthParameter('oauth_version', $oauth->getVersion());
     $request->setOAuthParameter('oauth_consumer_key', $oauth->getConsumer()->getKey());
     $request->setOAuthParameter('oauth_signature_method', $oauth->getSignature()->getName());
     if ($this->getKey() !== null) {
         $request->setOAuthParameter('oauth_token', $this->getKey());
     }
     $request->setOAuthParameter('oauth_signature', $oauth->getSignature()->generate($request, $oauth->getConsumer()->getSecret(), $this->getSecret()));
     $authorization = array();
     foreach ($request->getOAuthParameters() as $key => $value) {
         $authorization[] = sprintf('%s="%s"', $key, $value);
     }
     $request->setHeader('Authorization', sprintf('OAuth %s', implode(', ', $authorization)));
 }
Пример #2
0
 public function testGetHeadersWithOAuthParameters()
 {
     $this->request->setOAuthParameter('oauth_token', 'oauth_token');
     $this->assertFalse($this->request->hasHeaders());
     $this->assertTrue($this->request->hasOAuthParameter('oauth_token'));
     $this->assertEmpty($this->request->getHeaders());
 }