Files
php-curl-class/examples/post.php
T
Zach Borboa acf8e9f6a0 Include curl error code constant in curl error message (Curl::curlErrorMessage)
Before:
    Timeout was reached: Operation timed out after 30001 milliseconds with 1453867 out of 3000000 bytes received

After:
    Timeout was reached (CURLE_OPERATION_TIMEOUTED): Operation timed out after 30001 milliseconds with 1453867 out of 3000000 bytes received
2022-09-30 07:52:27 -07:00

21 lines
504 B
PHP

<?php
require __DIR__ . '/../vendor/autoload.php';
use Curl\Curl;
// curl --request POST "https://httpbin.org/post" --data "id=1&content=Hello+world%21&date=2015-06-30+19%3A42%3A21"
$curl = new Curl();
$curl->post('https://httpbin.org/post', [
'id' => '1',
'content' => 'Hello world!',
'date' => date('Y-m-d H:i:s'),
]);
if ($curl->error) {
echo 'Error: ' . $curl->errorMessage . "\n";
} else {
echo 'Data server received via POST:' . "\n";
var_dump($curl->response->form);
}