php对接网易云信视频直播
<?php
/**
* Created by PhpStorm.
* User: lhl
* Date: 2019/4/10
* Time: 17:31
*/ namespace app\api\controller; class Video
{
private $Nonce;
private $CurTime;
private $CheckSum;
const HEX_DIGITS = "0123456789abcdef";
public function __construct()
{
$this->AppKey = '自己网易云信的appkey';
$this->AppSecret = '自己网易云信的appsecret';
} /**生成验证码**/
public
function checkSumBuilder()
{
//此部分生成随机字符串
$hex_digits = self::HEX_DIGITS;
$this->Nonce;
for ($i = 0; $i < 128; $i++) {
//随机字符串最大128个字符,也可以小于该数
$this->Nonce .= $hex_digits[rand(0, 15)];
}
$this->CurTime = (string)(time());//当前时间戳,以秒为单位
$join_string = $this->AppSecret . $this->Nonce . $this->CurTime;
$this->CheckSum = sha1($join_string);
} /*****file_get_contents()post请求******/
public
function postDataCurl($url = 'https://vcloud.163.com/app/channellist', $data = array())
{
$this->checkSumBuilder();//发送请求前需先生成checkSum if (!empty($data)) {
$data = json_encode($data);
} else {
$data = "";
} $options = array(
'http' => array(
'method' => 'POST',
'header' => "Content-Type: application/json;charset=utf-8\r\n" . "AppKey:" . $this->AppKey . "\r\n" . "Nonce:" . $this->Nonce . "\r\n" .
"CurTime:" . $this->CurTime . "\r\n" . "CheckSum:" . $this->CheckSum . "",
'content' => $data,
'timeout' => 500,
)
);
$context = stream_context_create($options); $result = file_get_contents($url, false, $context); return json_decode($result, true);
} /***创建频道***/
public function channel_add($name, $type = 0)
{
$url = "https://vcloud.163.com/app/channel/create";
$data = $this->postDataCurl($url, array("name" => $name, "type" => $type));
// var_dump($data);
return json($data);
} /****修改频道*****/
public function channel_update($name, $cid, $type = 0)
{
$url = "https://vcloud.163.com/app/channel/update";
return $data = $this->postDataCurl($url, array("name" => $name, "cid" => $cid, "type" => $type));
} /****删除频道******/
public function channel_delete($cid)
{
$url = "https://vcloud.163.com/app/channel/delete";
return $data = $this->postDataCurl($url, array("cid" => $cid));
} /****获取频道状态******/
public function channel_get($cid)
{
$url = "https://vcloud.163.com/app/channelstats";
return $data = $this->postDataCurl($url, array("cid" => $cid));
} /***
* 获取频道列表
* records int 单页记录数,默认值为10 否
* pnum int 要取第几页,默认值为1 否
* ofield String 排序的域,支持的排序域为:ctime(默认) 否
* sort int 升序还是降序,1升序,0降序,默认为desc 否
* **/
public function channel_list($option = array("records" => 10, "pnum" => 1, "ofield" => "ctime", "sort" => 1))
{
$url = "https://vcloud.163.com/app/channellist";
return $data = $this->postDataCurl($url, $option);
} /**重新获取推流地址***/
public function channel_reset($cid)
{
$url = "https://vcloud.163.com/app/address";
return $data = $this->postDataCurl($url, array("cid" => $cid));
} /*****
* 设置频道为录制状态
* cid String 频道ID 是
* needRecord int 1-开启录制; 0-关闭录制 是
* format int 1-flv; 0-mp4 是
* duration int 录制切片时长(分钟),默认120分钟 否
* filename String 录制后文件名,格式为filename_YYYYMMDD-HHmmssYYYYMMDD-HHmmss,
* 文件名录制起始时间(年月日时分秒) -录制结束时间(年月日时分秒) 否
* ****/
public function channel_setRecord($cid, $option = array())
{
$url = "https://vcloud.163.com/app/channel/setAlwaysRecord";
return $data = $this->postDataCurl($url, $option);
} /****禁用频道*****/
public function channel_pause($cid)
{
$url = "https://vcloud.163.com/app/channel/pause";
return $data = $this->postDataCurl($url, array("cid" => $cid));
} /****批量禁用频道****/
public function channel_pauselist($cidList)
{
$url = "https://vcloud.163.com/app/channellist/pause";
return $data = $this->postDataCurl($url, array("cidList" => $cidList));
} /****恢复频道*****/
public function channel_resume($cid)
{
$url = "https://vcloud.163.com/app/channel/resume";
return $data = $this->postDataCurl($url, array("cid" => $cid));
} /****批量恢复频道****/
public function channel_resumelist($cidList)
{
$url = "https://vcloud.163.com/app/channellist/resume";
return $data = $this->postDataCurl($url, array("cidList" => $cidList));
} /****获取录制视频文件列表*****/
public function channel_videolist($cid)
{
$url = "https://vcloud.163.com/app/videolist";
return $data = $this->postDataCurl($url, array("cid" => $cid));
} /****获取某一时间范围的录制视频文件列表*****/
public function app_vodvideolist($cid, $beginTime, $endTime)
{
$url = "https://vcloud.163.com/app/vodvideolist";
return $data = $this->postDataCurl($url, array("cid" => $cid, "beginTime" => $beginTime, "endTime" => $endTime));
} /****设置视频录制回调地址*****/
public function record_setcallback($recordClk)
{
$url = "https://vcloud.163.com/app/record/setcallback";
return $data = $this->postDataCurl($url, array("recordClk" => $recordClk));
} /****设置回调的加签秘钥*****/
public function callback_setSignKey($signKey)
{
$url = "https://vcloud.163.com/app/callback/setSignKey";
return $data = $this->postDataCurl($url, array("signKey" => $signKey));
}
/****录制文件合并*****/
public function video_merge($outputName, $vidList)
{
$url = "https://vcloud.163.com/app/video/merge";
return $data = $this->postDataCurl($url, array("outputName" => $outputName, "vidList" => $vidList));
}
}
php对接网易云信视频直播的更多相关文章
- 对接网易云信音视频2.0呼叫组件集成到vue中,实现web端呼叫app,视频语音通话。
项目中需要实现视频通话功能,经过公司的赛选,采用网易云信的视频通话服务,app小伙伴集成很顺利.web端需要实现呼叫app端用户.网易云信文档介绍不全,vue的demo满足不了需求,和客服人员沟通,只 ...
- 网易云信融合CDN方案及实践
日前,网易云信视频云架构师席智勇在第七届GFIC全球家庭互联网大会进行了题为<网易云信融合CDN方案及实践>的分享,以下是演讲内容回顾. 图为 网易云信视频云架构师席智勇 CDN所面临的问 ...
- 音视频技术“塔尖”之争,网易云信如何C位出道?
音视频技术“塔尖”之争,网易云信如何C位出道? 社交+美颜.抖音短视频.在线狼人杀.直播竞答.子弹短信……,过往两三年间,互联网新产品和新玩法层出不穷,风口不断切换.这些爆红的网络应用背后,都有一些共 ...
- iOS中集成ijkplayer视频直播框架
ijkplayer 是一款做视频直播的框架, 基于ffmpeg, 支持 Android 和 iOS, 网上也有很多集成说明, 但是个人觉得还是不够详细, 在这里详细的讲一下在 iOS 中如何集成ijk ...
- 子弹短信光鲜的背后:网易云信首席架构师分享亿级IM平台的技术实践
本文原文内容来自InfoQ的技术分享,本次有修订.勘误和加工,感谢原作者的分享. 1.前言 自从2018年8月20日子弹短信在锤子发布会露面之后(详见<老罗最新发布了“子弹短信”这款IM,主打熟 ...
- 网易云信&七鱼市场总监姜菡钰:实战解读增长黑客在B端业务的运用
近些年 ,随着互联网的迅速崛起,“增长黑客”一词逐渐映入大众的眼帘,并成为了最热门的话题之一.从2018年开始,线上流量触达天花板,引流之争的激烈程度空前高涨,企业为了获得更多的关注,产品的比拼.流量 ...
- 响铃:蜗牛读书“文”、网易云信“武”:游戏之外网易的AB面
文|曾响铃来源|科技向令说(xiangling0815) 2019年开年,网易又"搞事情"了. 近日,网易集团旗下网易云信.网易七鱼主办的"网易MCtalk泛娱乐创新峰会 ...
- 从0到1构建网易云信IM私有化
本文来源于MOT技术管理课堂杭州站演讲实录,全文 2410 字,阅读约需 5分钟.网易云信资深研发工程师张翱从私有化面临的问题及需求说起,分享了网易云信IM私有化的解决方案和具体实践. 想要阅读更多技 ...
- 视频直播技术之iOS端推流
随着网络基础建设的发展和资费的下降,在这个内容消费升级的时代,文字.图片无法满足人们对视觉的需求,因此视频直播应运而生.承载了实时性Real-Time和交互性的直播云服务是直播覆盖各行各业的新动力.网 ...
随机推荐
- linux erlang环境安装
1.安装环境:yum -y install make gcc gcc-c++ kernel-devel m4 glibc-devel autoconfyum -y install ncurses-de ...
- [转]用python爬虫抓站的一些技巧总结 zz
来源网站:http://www.pythonclub.org/python-network-application/observer-spider 学用python也有3个多月了,用得最多的还是各类爬 ...
- The directory '/home/stone/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If execu
使用sudo pip install ......的时候出现下面一段黄色的代码: The directory '/home/stone/.cache/pip/http' or its parent d ...
- SQL Server 索引知识-结构,实现
索引的作用毋庸置疑,但他是如何组织,并实现提高语句访问效率的呢?本篇文章为大家做个详细的介绍. 聚集索引架构 B-tree 如图1-1 a.B-tree的结构,叶子节点为数据.数据按照聚集索引键有序排 ...
- .net验证是否合法邮箱和ip地址的方式
通常情况下第一时间会想到使用正则表达式去验证,但由于正则表达式过于复杂或者没有考虑到某些情况,从而导致问题或者判断的效率低.下面通过另一种方式去判断. 判断是否合法邮箱: /// <summar ...
- 一次存储链路抖动因I/O timeout不同在AIX和HPUX上的不同表现(转)
去年一个故障案例经过时间的沉淀问题没在发生今天有时间简单的总结一下,当时正时午睡时分,突然告警4库8个实例同时不可用,这么大面积的故障多数是有共性的关连,当时查看数据库DB ALERT日志都是I/O错 ...
- 转: 根据屏幕分辨率,浏览器调用不同css
<link type="text/csss" href="" rel="stylesheet"/> <link type= ...
- spider-抓取网页内容(Beautiful soup)
http://jingyan.baidu.com/article/afd8f4de6197c834e386e96b.html http://cuiqingcai.com/1319.html Windo ...
- Nav 切换
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- mysql 创建数据数据库 (避免新建的库名已经存在、设置编码)
1.创建数据库的 create database 数据库名 eg: Create database mydatabase 查看已创建的数据: show databases; 结果: 2.数据库名所对应 ...