|
@@ 37-50 (lines=14) @@
|
| 34 |
|
return $this->http($request); |
| 35 |
|
} |
| 36 |
|
|
| 37 |
|
public function postJson(string $url, array $data, array $headers = [], string $method = Request::POST): Message |
| 38 |
|
{ |
| 39 |
|
$headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 40 |
|
$headers['Accept'] = 'application/json'; |
| 41 |
|
$data_string = json_encode($data); |
| 42 |
|
$headers['Content-Length'] = strlen($data_string); |
| 43 |
|
$request = (new Message) |
| 44 |
|
->withType(Message::REQUEST) |
| 45 |
|
->withUrl($url) |
| 46 |
|
->withMethod($method) |
| 47 |
|
->withBody($data_string) |
| 48 |
|
->withHeaders($headers); |
| 49 |
|
return $this->http($request); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
public function postForm(string $url, array $data, array $headers = [], string $method = Request::POST): Message |
| 53 |
|
{ |
|
@@ 52-64 (lines=13) @@
|
| 49 |
|
return $this->http($request); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
public function postForm(string $url, array $data, array $headers = [], string $method = Request::POST): Message |
| 53 |
|
{ |
| 54 |
|
$headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8'; |
| 55 |
|
$data_string = http_build_query($data); |
| 56 |
|
$headers['Content-Length'] = strlen($data_string); |
| 57 |
|
$request = (new Message) |
| 58 |
|
->withType(Message::REQUEST) |
| 59 |
|
->withUrl($url) |
| 60 |
|
->withMethod($method) |
| 61 |
|
->withBody($data_string) |
| 62 |
|
->withHeaders($headers); |
| 63 |
|
return $this->http($request); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
public function delete(string $url, array $headers = []): Message |
| 67 |
|
{ |