查询字符串参数

你可以有多种方式来提供请求的查询字符串 你可以在请求的URI中设置查询字符串:

  1. $response = $client->request('GET', 'http://httpbin.org?foo=bar');

你可以使用 query 请求参数来声明查询字符串参数:

  1. $client->request('GET', 'http://httpbin.org', [
  2. 'query' => ['foo' => 'bar']
  3. ]);

提供的数组参数将会使用PHP的 http_build_query

最后,你可以提供一个字符串作为 query 请求参数:

  1. $client->request('GET', 'http://httpbin.org', ['query' => 'foo=bar']);