Horde_Oauth_Request::sign PHP Method

sign() public method

Sign this request in accordance with OAuth
public sign ( $signatureMethod, $consumer, $token = null ) : unknown_type
$signatureMethod
$consumer
$token
return unknown_type
    public function sign($signatureMethod, $consumer, $token = null)
    {
        if (empty($this->_params['oauth_consumer_key'])) {
            $this->_params['oauth_consumer_key'] = $consumer->key;
        }
        if (empty($this->_params['oauth_token']) && !empty($token)) {
            $this->_params['oauth_token'] = $token->key;
        }
        $this->_params['oauth_signature_method'] = $signatureMethod->getName();
        $this->_params['oauth_signature'] = $signatureMethod->sign($this, $consumer, $token);
        return $this->_getNormalizedUrl() . '?' . $this->buildHttpQuery();
    }

Usage Example

Esempio n. 1
0
 /**
  * Send a POST request to the twitter API. Purposely do not cache results
  * from these since POST requests alter data on the server.
  *
  * @see self::get
  */
 public function post($url, array $params = array())
 {
     $request = new Horde_Oauth_Request($url, $params);
     $request->sign($this->_twitter->auth->oauth->signatureMethod, $this->_twitter->auth->oauth, $this->_twitter->auth->getAccessToken($this->_request));
     $url = $url instanceof Horde_Url ? $url : new Horde_Url($url);
     try {
         $response = $this->_twitter->getHttpClient()->post($url->setRaw(true), $params, array('Authorization' => $request->buildAuthorizationHeader('Twitter API')));
     } catch (Horde_Http_Exception $e) {
         throw new Horde_Service_Twitter_Exception($e);
     }
     if ($response->code >= 400 && $response->code <= 500) {
         throw new Horde_Service_Twitter_Exception($response->getBody());
     }
     return $response->getBody();
 }
All Usage Examples Of Horde_Oauth_Request::sign