Unify Curl and MultiCurl examples

This commit is contained in:
Zach Borboa
2019-10-31 20:40:52 -07:00
parent 04d1db9d54
commit 33b748c71a
2 changed files with 7 additions and 3 deletions
+1
View File
@@ -5,3 +5,4 @@ use \Curl\Curl;
$curl = new Curl();
$curl->download('https://secure.php.net/images/logos/php-med-trans.png', '/tmp/php-med-trans.png');
$curl->download('https://upload.wikimedia.org/wikipedia/commons/c/c1/PHP_Logo.png', '/tmp/PHP_Logo.png');
@@ -3,10 +3,13 @@ require __DIR__ . '/../vendor/autoload.php';
use \Curl\Curl;
$curl = new Curl();
$curl->download('https://secure.php.net/images/logos/php-med-trans.png', function ($instance, $tmpfile) {
$callback = function ($instance, $tmpfile) {
$save_to_path = '/tmp/' . basename($instance->url);
$fh = fopen($save_to_path, 'wb');
stream_copy_to_stream($tmpfile, $fh);
fclose($fh);
});
};
$curl = new Curl();
$curl->download('https://secure.php.net/images/logos/php-med-trans.png', $callback);
$curl->download('https://upload.wikimedia.org/wikipedia/commons/c/c1/PHP_Logo.png', $callback);