1.下载sdk放入项目文件夹中

核心就是aliyun-php-sdk-core,它的配置文件会自动加载相应的类

2.引入文件

include_once LIB_PATH . 'ORG/aliyun-openapi/aliyun-php-sdk-core/Config.php';

3.配置客户端对象,需要Access Key ID,Access Key Secret

$iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "xxxx", "xxxx");  // Access Key ID,Access Key Secret
$client = new DefaultAcsClient($iClientProfile);

4.调用请求类,并配置参数,就拿直播推流历史为例

$request = new live\Request\V20161101\DescribeLiveStreamsPublishListRequest();
$request ->setDomainName('live.yunlutong.com');
$request ->setAppName('yunlutong');
$request ->setStreamName('demo');
$request ->setStartTime('2017-03-01T19:00:00Z');
$request ->setEndTime('2017-03-29T19:00:00Z');

5.发起请求

//针对阿里云进行请求
$response = $client->getAcsResponse($request);
exit(json_encode($response));

完整代码如下

<?php

/**
* 直播相关接口
*/
class LiveAction extends ApiAction
{
protected function _initialize()
{
parent::_initialize();
} // 获取推流历史
public function DescribeLiveStreamsPublishList() {
include_once LIB_PATH . 'ORG/aliyun-openapi/aliyun-php-sdk-core/Config.php'; $iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "xxxx", "xxxx"); // Access Key ID,Access Key Secret
$client = new DefaultAcsClient($iClientProfile); $request = new live\Request\V20161101\DescribeLiveStreamsPublishListRequest();
$request ->setDomainName('live.yunlutong.com');
$request ->setAppName('yunlutong');
$request ->setStreamName('demo');
$request ->setStartTime('2017-03-01T19:00:00Z');
$request ->setEndTime('2017-03-29T19:00:00Z'); //针对阿里云进行请求
$response = $client->getAcsResponse($request);
exit(json_encode($response));
} }

获取数据如下

其他的接口数据,类似。

这是官方的接口调用文档,

最新文章

  1. jQuery外链新窗口打开
  2. python django 多级业务树形结构规划及页面渲染
  3. uva11426 gcd、欧拉函数
  4. C/C++ 结构体 函数传递
  5. CoreCLR on Mac:体验managed exception handling
  6. c创建win窗口
  7. RHCE ext3文件系统故障一例
  8. html-----011--子窗体iframe
  9. Erlang常用代码段
  10. 教学小例子:简易的webSevrer
  11. mysql主从同步+mycat读写分离+.NET程序连接mycat代理
  12. orale 查询每年、每月、每日统计量的sql语句
  13. Java与算法之(2) - 快速排序
  14. 51Nod 1482 部落信号
  15. 发布 Rafy .NET Standard 版本 Nuget 包
  16. java 根据某个数字,计算前后多少天的具体日期
  17. 详解封装微信小程序组件及小程序坑(附带解决方案)
  18. 注册MongoDB为系统服务(二)
  19. UVA11997 K Smallest Sums
  20. yii2restful规范的api使用

热门文章

  1. yii2:属性
  2. angular服务
  3. CodeForces - 197D
  4. idea maven打包 install 报错The packaging for this project did not assign a file to the build artifact
  5. gulp 相关文章
  6. python递归 及 面向对象初识及编程思想
  7. 【2018年全国多校算法寒假训练营练习比赛(第五场)-E】情人节的电灯泡(二维树状数组单点更新+区间查询)
  8. poj2446
  9. set, map, string, find(), string name[100],等的混合
  10. hibernate validate验证框架中@NotEmpty、@NotbBank、@NotNull的区别