阿里云openapi接口使用,PHP,视频直播
生活随笔
收集整理的這篇文章主要介紹了
阿里云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 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));完整代碼如下
/*** 直播相關接口*/ 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));}}獲取數據如下
其他的接口數據,類似。
這是官方的接口調用文檔,
本文轉自TBHacker博客園博客,原文鏈接:http://www.cnblogs.com/jiqing9006/p/6599492.html,如需轉載請自行聯系原作者
總結
以上是生活随笔為你收集整理的阿里云openapi接口使用,PHP,视频直播的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab除法
- 下一篇: php设置cookie值,PHP如何设置