Zend_Http_Client::setRawData PHP Method

setRawData() public method

This function is here for two reasons: 1. For advanced user who would like to set their own data, already encoded 2. For backwards compatibilty: If someone uses the old post($data) method. this method will be used to set the encoded data. $data can also be stream (such as file) from which the data will be read.
public setRawData ( string | resource $data, string $enctype = null ) : Zend_Http_Client
$data string | resource
$enctype string
return Zend_Http_Client
    public function setRawData($data, $enctype = null)
    {
        $this->raw_post_data = $data;
        $this->setEncType($enctype);
        if (is_resource($data)) {
            // We've got stream data
            $stat = @fstat($data);
            if ($stat) {
                $this->setHeaders(self::CONTENT_LENGTH, $stat['size']);
            }
        }
        return $this;
    }

Usage Example

Beispiel #1
0
 public function sayRoom($room, $message, $type = 'TextMessage')
 {
     $uri = 'https://' . $this->subdomain . '.campfirenow.com/room/' . $room . '/speak.json';
     $this->client->setUri($uri);
     $params['message']['type'] = $type;
     $params['message']['body'] = $message;
     $this->client->setHeaders('Content-type', 'application/json');
     $this->client->setRawData(json_encode($params));
     $this->client->setMethod(Zend_Http_Client::POST);
     $response = $this->client->request();
     return (bool) ($response->getStatus() == 200);
 }
All Usage Examples Of Zend_Http_Client::setRawData