zoukankan      html  css  js  c++  java
  • 阿里云openapi接口使用,PHP,视频直播

    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 liveRequestV20161101DescribeLiveStreamsPublishListRequest();
    $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 liveRequestV20161101DescribeLiveStreamsPublishListRequest();
            $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));
        }
    
    }
    

    获取数据如下

    其他的接口数据,类似。

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

  • 相关阅读:
    LowercaseRoutesMVC ASP.NET MVC routes to lowercase URLs
    Asp.net MVC Combres的简单用法
    原码, 反码, 补码 详解
    四种数据存储结构---顺序存储 链接存储 索引存储 散列存储
    快速排序时间复杂度为O(n×log(n))的证明
    进程与线程及其区别
    linux c语言定时器
    平衡二叉查找树的一些知识总结
    C++编程练习(17)----“二叉树非递归遍历的实现“
    C++编程练习(16)----“排序算法 之 快速排序“
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/6599492.html
Copyright © 2011-2022 走看看