dannymeyer/guzzlehttp-multicurl

v1.0.0 2020-09-19 22:55 UTC

README

一个用于简化GuzzleHttp异步多curl请求的助手

使用方法

$curl = new \DannyMeyer\Curl\Multicurl();

$curl->addGetRequestByUri('https://my.domain/ExampleRequest');
$curl->addGetRequestByUri('https://my.domain/AnotherExampleRequest');

$result = $curl->execute();

if ($curl->hasErrors()) {
    var_dump($curl->getErrors());
}

添加带认证的请求

$curl = new \DannyMeyer\Curl\Multicurl();
$request = new \GuzzleHttp\Psr7\Request(
    'get',
    'https://my.domain/ExampleRequest',
    ['Authorization' => 'Basic ' . \base64_encode('User:Password')]
);

$curl->addRequest($request);