buildAuthorizationHeader() public method

public buildAuthorizationHeader ( $realm = '' )
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();
 }