我将以下代码作为:
public function postGuzzleRequest()
{
$client = new \GuzzleHttp\Client();
$url = "http://myexample.com/api/posts";
$myBody['name'] = "Demo";
$request = $client->post($url, ['body'=>$myBody]);
$response = $request->send();
dd($response);
}
现在我试图在异步模式下使用它
答案 0 :(得分:0)
直接从doc获取: http://docs.guzzlephp.org/en/stable/quickstart.html
$promise = $client->getAsync('http://httpbin.org/get');
$promise = $client->deleteAsync('http://httpbin.org/delete');
$promise = $client->headAsync('http://httpbin.org/get');
$promise = $client->optionsAsync('http://httpbin.org/get');
$promise = $client->patchAsync('http://httpbin.org/patch');
$promise = $client->postAsync('http://httpbin.org/post');
$promise = $client->putAsync('http://httpbin.org/put');