Add POST examples

This commit is contained in:
Zach Borboa
2015-07-07 10:51:47 -07:00
parent 2e56b4b435
commit 2fd09c6061
2 changed files with 39 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
<?php
require '../src/Curl/Curl.php';
use \Curl\Curl;
// curl \
// -X POST \
// -d "id=1&content=Hello+world%21&date=2015-06-30+19%3A42%3A21" \
// "https://httpbin.org/post"
$data = array(
'id' => '1',
'content' => 'Hello world!',
'date' => date('Y-m-d H:i:s'),
);
$curl = new Curl();
$curl->post('https://httpbin.org/post', $data);
var_dump($curl->response->form);
+20
View File
@@ -0,0 +1,20 @@
<?php
require '../src/Curl/Curl.php';
use \Curl\Curl;
// curl \
// -X POST \
// -d "{"id":"1","content":"Hello world!","date":"2015-06-30 19:42:21"}" \
// "https://httpbin.org/post"
$data = json_encode(array(
'id' => '1',
'content' => 'Hello world!',
'date' => date('Y-m-d H:i:s'),
));
$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json');
$curl->post('https://httpbin.org/post', $data);
var_dump($curl->response->json);