我試圖通過POOL在發送庫中發送POST數據。但是,在數據發送的地址POST是完全空的 - 我不明白。GuzzleHttps - 如何發送異步。數據通過POST(使用池)
$client = new Client();
$requests = function()
{
foreach($this->urls as $url)
{
yield new Request('POST', $url, [
'body' => '...'
]);
}
};
我也試過form_params和multipart內容,不工作了(POST是空的也再次$ _REQUEST & $ _GET)。
當然這一段代碼(出於完整性):
$pool = new Pool($client, $requests(), [
'concurrency' => count($this->urls),
'fulfilled' => function ($response) {},
'rejected' => function ($reason) {},
});
$promise = $pool->promise();
$promise->wait();
狂飲正確地發送請求(第二服務器上輸入),但其本身不具有任何數據。
我在做什麼錯?謝謝!
編輯:
我只是想將這段代碼有狂飲(重複的週期現在):
$ch = curl_init();
$url = 'https://example.cop';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, 'mehehe_net');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 59000);
curl_setopt($ch, CURLOPT_POST, true);
$dt = ["data" => json_encode($queue)];
curl_setopt($ch, CURLOPT_POSTFIELDS, $dt);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$cont = curl_exec($ch);
curl_close($ch);