Add multicurl download example with success, error, and complete callbacks

This commit is contained in:
Zach Borboa
2016-12-23 00:55:16 -08:00
parent bd75d8a0cc
commit 80f874b7c2
2 changed files with 22 additions and 1 deletions
@@ -0,0 +1,21 @@
<?php
require __DIR__ . '/vendor/autoload.php';
use \Curl\MultiCurl;
$multi_curl = new MultiCurl();
$multi_curl->success(function ($instance) {
echo 'call to "' . $instance->url . '" was successful.' . "\n";
});
$multi_curl->error(function ($instance) {
echo 'call to "' . $instance->url . '" was unsuccessful.' . "\n";
echo 'error code: ' . $instance->errorCode . "\n";
echo 'error message: ' . $instance->errorMessage . "\n";
});
$multi_curl->complete(function ($instance) {
echo 'call to "' . $instance->url . '" completed.' . "\n";
});
$multi_curl->addDownload('https://secure.php.net/images/logos/php-med-trans.png', '/tmp/php-med-trans.png');
$multi_curl->addDownload('https://upload.wikimedia.org/wikipedia/commons/c/c1/PHP_Logo.png', '/tmp/PHP_Logo.png');
$multi_curl->start();
+1 -1
View File
@@ -15,7 +15,7 @@ $multi_curl->error(function ($instance) {
echo 'error message: ' . $instance->errorMessage . "\n";
});
$multi_curl->complete(function ($instance) {
echo 'call completed' . "\n";
echo 'call to "' . $instance->url . '" completed.' . "\n";
});
$multi_curl->addGet('https://www.google.com/search', array(