hyperf使用guzzle请求第三方外部接口api

在hyperf中如何调用外部接口

安装`composer require hyperf/guzzle`

代码如下

```
'http://www.test.com.cn',
'handler' => HandlerStack::create(new CoroutineHandler()),
'timeout' => 5,
'swoole' => [ // 看这里看这里
'timeout' => 10,
'socket_buffer_size' => 1024 * 1024 * 2,
],
]);

$response = $client->get('/index/goods/list/is_ajax/1?goods_type=2 ');
error_log(print_r($response->getBody()->getContents(),true),3,"/tmp/1.txt");

$result = $response->getBody()->getContents();
return $result;
}
}
```

    A+
发布日期:2021年12月30日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: