MultiRequestService multiPost($urls)
- 用法
基于GuzzleHttp
的并发POST请求。
MultiRequestService
对象方法列表:
concurrency()
:设置并发数withOptions()
:设置GuzzleHttp的一些其他选项withHeaders()
: 设置HTTP Headersuccess()
: HTTP success回调函数error()
: HTTP error回调函数send()
: 发送请求
用法
用法同multiGet()
.
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();