Skip to content

Commit 2fd09c6

Browse files
committed
Add POST examples
1 parent 2e56b4b commit 2fd09c6

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

examples/post.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
require '../src/Curl/Curl.php';
3+
4+
use \Curl\Curl;
5+
6+
// curl \
7+
// -X POST \
8+
// -d "id=1&content=Hello+world%21&date=2015-06-30+19%3A42%3A21" \
9+
// "https://httpbin.org/post"
10+
11+
$data = array(
12+
'id' => '1',
13+
'content' => 'Hello world!',
14+
'date' => date('Y-m-d H:i:s'),
15+
);
16+
17+
$curl = new Curl();
18+
$curl->post('https://httpbin.org/post', $data);
19+
var_dump($curl->response->form);

examples/post_json.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
require '../src/Curl/Curl.php';
3+
4+
use \Curl\Curl;
5+
6+
// curl \
7+
// -X POST \
8+
// -d "{"id":"1","content":"Hello world!","date":"2015-06-30 19:42:21"}" \
9+
// "https://httpbin.org/post"
10+
11+
$data = json_encode(array(
12+
'id' => '1',
13+
'content' => 'Hello world!',
14+
'date' => date('Y-m-d H:i:s'),
15+
));
16+
17+
$curl = new Curl();
18+
$curl->setHeader('Content-Type', 'application/json');
19+
$curl->post('https://httpbin.org/post', $data);
20+
var_dump($curl->response->json);

0 commit comments

Comments
 (0)