composer require guzzlehttp/guzzle 发送GET请求 require 'vendor/autoload.php'; use GuzzleHttp\Client; $client = new Client(); $response = $client->get('http://httpbin.org/get', [ 'query' => [ 'name' => 'Tom' ]); echo $response->getStatusCode(); // 200 $content = $response->getBody()->getContents(); print_r($content); 发送POST请求 require 'vendor/autoload.php'; use GuzzleHttp\Client; $client = new Client(); $response = $client->post('http://httpbin.org/post', [ 'json' => [ 'name' => 'Tom' ]); echo $response->getStatusCode(); // 200 $content = $response->getBody()->getContents(); print_r($content);