阿里云openapi接口使用,PHP,视频直播

1.下载sdk放入项目文件夹中
422101-20170322134203674-1670232808.png

422101-20170322134209268-699095042.png

422101-20170322134216502-1641713123.png

核心就是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));
    }

}

获取数据如下

422101-20170322135113268-309462513.png

其他的接口数据,类似。

这是官方的接口调用文档,
422101-20170322135359408-1024521299.png


本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/6599492.html,如需转载请自行联系原作者

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值