吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 8767|回复: 49
收起左侧

[其他转载] 萤石云视频WEB开发

[复制链接]
pengxuanlan 发表于 2021-7-6 14:45
本帖最后由 pengxuanlan 于 2021-7-6 14:52 编辑

1、首先你需要去萤石开放平台,申请开发者帐号(这个我就不啰嗦了https://open.ys7.com/cn/s/index)
2、申请完之后,你会得到一个AccessToken,开发过程中,需要使用到这个,有效期一般为7天
image.png
3、AccessToken过期后可以使用AppKey和密钥生成新的Token
[PHP] 纯文本查看 复制代码
$appKey = "57ec14********62e254";
$secret = "6fd9****************dbb1f15c";
$url="https://open.ys7.com/api/lapp/token/get";  
$data1 = ["appKey" => $appKey,"appSecret"=>"$secret"];
$myfile = fopen("time.txt", "r") or die("Unable to open file!");
$time2= fread($myfile,filesize("time.txt"));
$time = time();
if($time>$time2){   //失效了,重新获取,正常的话不执行操作
$content1 = posturl($url, $data1)['data'];
$accesstoken=$content1['accessToken'];
$expiretime = $content1['expireTime'];
$myfile = fopen("time.txt", "w") or die("Unable to open file!");
$txt = substr($expiretime,0,10);
fwrite($myfile, $txt);
fclose($myfile);
$myfile = fopen("accesstoken.txt", "w") or die("Unable to open file!");
$txt = $accesstoken;
fwrite($myfile, $txt);
fclose($myfile);
}
$myfile = fopen("accesstoken.txt", "r") or die("Unable to open file!");
$AccessToken= fread($myfile,filesize("accesstoken.txt"));
function posturl($url, $data)
{
 //把数组形式的参数转为‘appkey=....&secret=...'这种形式;
    $data = http_build_query($data);
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_BINARYTRANSFER, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($curl);
    curl_close($curl);
    //输出结果;
    return json_decode($output, true);
}

保存好这个Token,方便下次调用
4、在线预览视频
[PHP] 纯文本查看 复制代码
$xlh =$_GET['xlh'];       //序列号取过来
$myfile = fopen("accesstoken.txt", "r") or die("Unable to open file!");  //打开Token文件取出Token
$AccessToken= fread($myfile,filesize("accesstoken.txt"));
echo "<iframe src='https://open.ys7.com/ezopen/h5/iframe_se?url=ezopen://open.ys7.com/{$xlh}/1.live&autoplay=1&audio=0&accessToken={$AccessToken}&hd=1&templete=2' width='800' height='600' id='ysopen' allowfullscreen></iframe>";

还有一些操作的功能, 比如云台,加密,删除,改名之类的,接到对应的接口,直接POST就行了

免费评分

参与人数 2吾爱币 +2 热心值 +2 收起 理由
越飞越远 + 1 + 1 谢谢@Thanks!
坐久落花多 + 1 + 1 有效期7天。。。太短了吧

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

rabbit2008 发表于 2021-7-7 10:43
预览的视频页面报错
Notice: Undefined index: xlh in D:\PHP\root\view.php on line 2

Warning: fopen(accesstoken.txt): failed to open stream: No such file or directory in D:\PHP\root\view.php on line 3
Unable to open file!

token获取的页面报错
Warning: fopen(time.txt): failed to open stream: No such file or directory in D:\PHP\root\token.php on line 6
Unable to open file!
 楼主| pengxuanlan 发表于 2021-7-6 14:47
宜城小站 发表于 2021-7-6 15:18
A-Game 发表于 2021-7-6 16:11
正是需要的时候
rabbit2008 发表于 2021-7-6 16:34
每隔几天就需要更新一次token
太麻烦
ynjian 发表于 2021-7-6 16:57
不会用,,,,
 楼主| pengxuanlan 发表于 2021-7-6 17:32
rabbit2008 发表于 2021-7-6 16:34
每隔几天就需要更新一次token
太麻烦

上面的代码有自动更新Token
jeonlee 发表于 2021-7-6 17:34
每隔几天就需要更新一次token
tangosweet 发表于 2021-7-6 17:49
看不懂,顶原创
jardy129 发表于 2021-7-6 17:51
给有需要的的吧
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-3 10:57

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表