guzzle不知不覺升級到六,升級以後和原來3.*的時候用法不一樣了,看文檔也迷糊,找了半天才從文檔找到用法:
POST
$response = $client->request('POST', 'http://httpbin.org/post', [
'form_params' => [
'field_name' => 'abc',
'other_field' => '123',
'nested_field' => [
'nested' => 'hello'
]
]
]);
$result = $response->getBody();
GET
$client = new Client();
$res = $client->request('GET', $url . "?param1=1¶m2=9");
$result = $res->getBody();
講道理,還是挺方便的。