mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-10-10 05:55:32 +00:00
Update multi curl example in readme; Add multi curl examples
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
require '../src/Curl/Curl.php';
|
||||
require '../src/Curl/MultiCurl.php';
|
||||
|
||||
use \Curl\Curl;
|
||||
use \Curl\MultiCurl;
|
||||
|
||||
$multi_curl = new MultiCurl();
|
||||
|
||||
$multi_curl->success(function($instance) {
|
||||
echo 'call to "' . $instance->url . '" was successful.' . "\n";
|
||||
echo 'response: ' . $instance->response . "\n";
|
||||
});
|
||||
$multi_curl->error(function($instance) {
|
||||
echo 'call to "' . $instance->url . '" was unsuccessful.' . "\n";
|
||||
echo 'error code: ' . $instance->error_code . "\n";
|
||||
echo 'error message: ' . $instance->error_message . "\n";
|
||||
});
|
||||
$multi_curl->complete(function($instance) {
|
||||
echo 'call completed' . "\n";
|
||||
});
|
||||
|
||||
$multi_curl->addGet('https://www.google.com/search', array(
|
||||
'q' => 'hello world',
|
||||
));
|
||||
$multi_curl->addGet('https://duckduckgo.com/', array(
|
||||
'q' => 'hello world',
|
||||
));
|
||||
$multi_curl->addGet('https://www.bing.com/search', array(
|
||||
'q' => 'hello world',
|
||||
));
|
||||
|
||||
$multi_curl->start();
|
||||
Reference in New Issue
Block a user