MultiRequestService multiPost($urls)
基于GuzzleHttp的并发POST请求。
MultiRequestService对象方法列表:
concurrency():设置并发数withOptions():设置GuzzleHttp的一些其他选项withHeaders(): 设置HTTP Headersuccess(): HTTP success回调函数error(): HTTP error回调函数send(): 发送请求
用法
用法同multiGet().
php
use GuzzleHttp\Psr7\Response;
use QL\QueryList;
$requests = [
new Request('POST','http://httpbin.org/post',[
'Content-Type' => 'application/x-www-form-urlencoded',
'User-Agent' => 'g-http'
],http_build_query([
'name' => 'php'
])),
new Request('POST','http://httpbin.org/post',[
'Content-Type' => 'application/x-www-form-urlencoded',
'User-Agent' => 'g-http'
],http_build_query([
'name' => 'go'
])),
new Request('POST','http://httpbin.org/post',[
'Content-Type' => 'application/x-www-form-urlencoded',
'User-Agent' => 'g-http'
],http_build_query([
'name' => 'c#'
]))
];
QueryList::multiPost($requests)
->success(...)
->send();use GuzzleHttp\Psr7\Response;
use QL\QueryList;
$requests = [
new Request('POST','http://httpbin.org/post',[
'Content-Type' => 'application/x-www-form-urlencoded',
'User-Agent' => 'g-http'
],http_build_query([
'name' => 'php'
])),
new Request('POST','http://httpbin.org/post',[
'Content-Type' => 'application/x-www-form-urlencoded',
'User-Agent' => 'g-http'
],http_build_query([
'name' => 'go'
])),
new Request('POST','http://httpbin.org/post',[
'Content-Type' => 'application/x-www-form-urlencoded',
'User-Agent' => 'g-http'
],http_build_query([
'name' => 'c#'
]))
];
QueryList::multiPost($requests)
->success(...)
->send();