swoft的SaberGM如何使用

阅读 5.3k
2 个回答
新手上路,请多包涵

$res = SaberGM::get('http://httpbin.org/get')->getBody();

如果返回结果是是json format string可以这样直接拿到json解析数组
->getParsedJsonArray()

推荐下我的宇润 PHP 全家桶之 YurunHttp:https://github.com/yurunsoft/...

同样支持 Swoole 协程化,除此之外也支持 Curl。同一套写法,兼容 fpm、Swoole 环境~

use Yurun\Util\HttpRequest;

$http = new HttpRequest;
$response = $http->get('https://test-xxx.com/course/list');
$data = $response->json();