鉴于官方API过度设计,所以这个中间件是GuzzleHttp专用的,支持阿里云大部分API请求。
use GuzzleHttp\Cliet;use GuzzleHttp\HadlerStack;use aliyu\guzzle\subscriber\Rpc;$stack = HadlerStack::create();//跟guzzlephp普通用法唯一的区别就是这里吧中间件加载进来,他会自动帮你签名重新包装请求参数。$middleware = ew Rpc([ 'accessKeyId' => '123456', 'accessSecret' => '654321',]);$stack->push($middleware);//这里设置 网关地址,数组参数请参见 https://docs.guzzlephp.org/e/latest/request-optios.html 操作哪个接口对应的 base_uri 就写哪个$cliet = ew Cliet([ 'base_uri' => 'https://live.aliyucs.com/', 'hadler' => $stack,]);//查询参数 https://help.aliyu.com/documet_detail/35412.html 这个页面列出了几个参数就在数组提交几个参数,其他的API接口也一样,只需对应参数给他提交即可。$res = $cliet->get('/', [ 'query' => [ 'Actio' => 'DescribeLiveStreamOlieUserNum', 'DomaiName' => 'live.aaa.tv', 'AppName' => 'live', 'StreamName' => 'bbb', ]]);prit_r($res->getBody()->getCotets());点击空白处退出提示










评论