post() public méthode

Fetches the page content with a POST request.
public post ( string/SimpleUrl $url, hash/SimpleFormEncoding $parameters = false, string $content_type = false ) : string
$url string/SimpleUrl
$parameters hash/SimpleFormEncoding
$content_type string MIME Content-Type of the request body
Résultat string Content of page.
 function testPost()
 {
     $browser = new SimpleBrowser();
     $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
     $this->assertTrue($browser->post('http://www.lastcraft.com/test/network_confirm.php'));
     $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
     $this->assertPattern('/Request method.*?<dd>POST<\\/dd>/', $browser->getContent());
 }
Exemple #2
0
 function testPostWithXmlEncoding()
 {
     $browser = new SimpleBrowser();
     $this->assertTrue($browser->post($this->samples() . 'request_methods.php', '<a><b>c</b></a>', 'text/xml'));
     $this->assertEqual($browser->getResponseCode(), 201);
     $this->assertPattern('/c/', $browser->getContent());
 }