mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-18 23:02:21 +00:00
45a7b1b671
* Adding methods like Curl::setGet() for each HTTP request method
Adding these methods to separate the request initialization from the
execution.
Methods added:
Curl::setDelete()
Curl::setGet()
Curl::setHead()
Curl::setOptions()
Curl::setPatch()
Curl::setPost()
Curl::setPut()
Curl::setSearch()
* Fix loading local test servers
Error message:
+++ declare -A pids
run_phpunit.sh: line 77: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
Error message:
+++ server_count=7
+++ pids=()
run_phpunit.sh: line 85: "7" - 1: syntax error: operand expected (error token is ""7" - 1")
* Clean up
34 lines
747 B
PHP
34 lines
747 B
PHP
<?php
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
use Curl\Curl;
|
|
use Curl\MultiCurl;
|
|
|
|
$multi_curl = new MultiCurl();
|
|
$multi_curl->complete(function ($instance) {
|
|
echo 'call to "' . $instance->url . '" completed.' . "\n";
|
|
});
|
|
|
|
$curl_1 = new Curl();
|
|
$curl_1->setOpt(CURLOPT_POST, true);
|
|
$curl_1->setOpt(CURLOPT_POSTFIELDS, [
|
|
'to' => 'alice',
|
|
'subject' => 'hi',
|
|
'body' => 'hi Alice',
|
|
]);
|
|
$curl_1->setUrl('https://httpbin.org/post');
|
|
$multi_curl->addCurl($curl_1);
|
|
|
|
$curl_2 = new Curl();
|
|
$curl_2->setOpt(CURLOPT_POST, true);
|
|
$curl_2->setOpt(CURLOPT_POSTFIELDS, [
|
|
'to' => 'bob',
|
|
'subject' => 'hi',
|
|
'body' => 'hi Bob',
|
|
]);
|
|
$curl_2->setUrl('https://httpbin.org/post');
|
|
$multi_curl->addCurl($curl_2);
|
|
|
|
$multi_curl->start();
|