阿里云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,如需转载请自行联系原作者

相关文章
|
2月前
|
消息中间件 API PHP
阿里云OpenAPI RocketMQ 5.0的PHP收发消息文档
【2月更文挑战第23天】阿里云OpenAPI RocketMQ 5.0的PHP收发消息文档
42 7
|
4月前
|
消息中间件 PHP 开发工具
阿里云OpenAPI RocketMQ 5.0的PHP收发消息文档可以在阿里云开发者门户中找到
【1月更文挑战第22天】【1月更文挑战第108篇】阿里云OpenAPI RocketMQ 5.0的PHP收发消息文档可以在阿里云开发者门户中找到
61 6
|
7月前
|
Java PHP
阿里云OpenAPI并没有专门为PHP提供的示例代码
阿里云OpenAPI并没有专门为PHP提供的示例代码
50 1
|
9月前
|
PHP 开发工具
阿里云OpenAPI的PHP SDK
阿里云OpenAPI的PHP SDK
229 3
|
JSON PHP 数据格式
阿里云openapi签名实现代码(基于PHP)
简介: 部分开发者在接触阿里云openAPi调用的时候,Signature的构造和生成一直都是一只拦路虎,本文中将基于PHP,和点播的APi:getVideoPlayAuth 实现签名的构造,仅供大家参考。
1490 0
阿里云openapi签名实现代码(基于PHP)
|
8月前
|
关系型数据库 MySQL PHP
PHP 原生操作 Mysql
PHP 原生操作 Mysql
82 0
|
8月前
|
关系型数据库 MySQL 数据库连接
PHP 原生连接 Mysql
PHP 原生连接 Mysql
108 0
|
8月前
|
关系型数据库 MySQL Unix
PHP MySql 安装与连接
PHP MySql 安装与连接
134 0
|
4月前
|
关系型数据库 MySQL PHP