lithium\net\http\Service::post PHP Method

post() public method

Send POST request.
public post ( string $path = null, array $data = [], array $options = [] ) : string
$path string
$data array
$options array
return string
    public function post($path = null, $data = array(), array $options = array())
    {
        return $this->send(__FUNCTION__, $path, $data, $options);
    }

Usage Example

Example #1
0
 public function testJsonPost()
 {
     $http = new Service($this->_testConfig);
     $http->post('update.xml', array('status' => 'cool'), array('type' => 'json'));
     $expected = join("\r\n", array('POST /update.xml HTTP/1.1', 'Host: localhost:80', 'Connection: Close', 'User-Agent: Mozilla/5.0', 'Content-Type: application/json', 'Content-Length: 17', '', '{"status":"cool"}'));
     $result = (string) $http->last->request;
     $this->assertEqual($expected, $result);
     $expected = join("\r\n", array('HTTP/1.1 200 OK', 'Host: localhost:80', 'Connection: Close', 'User-Agent: Mozilla/5.0', 'Content-Type: application/json', 'Content-Length: 17', '', '{"status":"cool"}'));
     $result = (string) $http->last->response;
     $this->assertEqual($expected, $result);
 }