• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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));
    }

}

获取数据如下

其他的接口数据,类似。

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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
【php增删改查实例】第十二节-数据删除功能发布时间:2022-07-10
下一篇:
PHP控制阿里云短信API接口实现短信群发功能发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap