Php 如何在Guzzle6中创建批处理请求?
我需要发送多个请求,所以我想实现一个批处理请求 我们怎样才能在狂饮中做到这一点 使用旧方法:Php 如何在Guzzle6中创建批处理请求?,php,guzzle,guzzle6,Php,Guzzle,Guzzle6,我需要发送多个请求,所以我想实现一个批处理请求 我们怎样才能在狂饮中做到这一点 使用旧方法: $client->send(array( $client->get($courses), //api url $client->get($job_categories), //api url )); 给了我一个错误: GuzzleHttp\Client::send() must implement interface Psr\Http\Message\Reques
$client->send(array(
$client->get($courses), //api url
$client->get($job_categories), //api url
));
给了我一个错误:
GuzzleHttp\Client::send() must implement interface Psr\Http\Message\RequestInterface, array given
试试这样的
$client = new Client();
foreach ($links as $link) {
$requests[] = new Request('GET', $link);
}
$responses = Pool::batch($client, $requests, array(
'concurrency' => 15,
));
foreach ($responses as $response) {
//do something
}
别忘了
use GuzzleHttp\Pool;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;