生成实例

适用API代理服务

  1. $saber = Saber::create([
  2. 'base_uri' => 'http://httpbin.org',
  3. 'headers' => [
  4. 'Accept-Language' => 'en,zh-CN;q=0.9,zh;q=0.8',
  5. 'Content-Type' => ContentType::JSON,
  6. 'DNT' => '1',
  7. 'User-Agent' => null
  8. ]
  9. ]);
  10. echo $saber->get('/get');
  11. echo $saber->delete('/delete');
  12. echo $saber->post('/post', ['foo' => 'bar']);
  13. echo $saber->patch('/patch', ['foo' => 'bar']);
  14. echo $saber->put('/put', ['foo' => 'bar']);