• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php和腾讯直播的实现代码

php 搞代码 4年前 (2022-01-04) 30次浏览 已收录 0个评论

戏说前文
不要想太多,直播和你(php)没啥关系、帮忙配置一下推拉流地址和License、然后生成一下推拉流地址详细链接就好了
但是,像是送礼物,弹幕自己写长连接或调用im。家族,充币等都是逻辑问题,这里就不说了
下面

第一步 配置推拉流地址

bizid

appkey

第二步:生成地址

像这样生成

if (!function_exists('create_live')) {

   function create_live($user_id = 0) {

    $live_bizid = Config::get("site.live_bizid");//直播bizid
    $live_sdkapp_id = Config::get("site.live_<strong style="color:transparent">来源gaodaima#com搞(代@码网</strong>sdkapp_id");//直播sdkapp_id
    $push_domain = Config::get("site.push_domain");//推流域名
    $play_domain = Config::get("site.play_domain");//播放域名
    $live_key = Config::get("site.live_key");//直播key
    $live_expiry_time = Config::get("site.live_expiry_time");//直播过期时间
    

    $livecode = $live_sdkapp_id.'_'.$user_id;
    //默认名// 推荐用随机数字或者用户 ID
    if ($live_key && $live_expiry_time) {

      $time = time()+$live_expiry_time;
      //过期时间
      //strtoupper把所有字符转换为大写 base_convert把进制数转换:
      $txTime = strtoupper(base_convert($time,10,16));
      //加密
      $txSecret = md5($live_key.$livecode.$txTime);
      //StreamName(流 ID):推荐用随机数字或者用户 ID。
      //bizid 直播bizid
      //txTime(地址有效期):何时该 URL 会过期,格式支持十六进制的 UNIX 时间戳。
      //txSecret(防盗链签名):防止攻击者伪造您的后台生成推流 URL 
      $ext_str = '?'.http_build_query(array(
        "bizid" => $live_bizid,
        "txSecret" => $txSecret,
        "txTime" => $txTime
      ));
    }

    $url = [
      "push_url" => "rtmp://".$push_domain."/live/".$livecode.(isset($ext_str) ? $ext_str : ""),
      "rtmp_play_url" => "rtmp://".$play_domain."/live/".$livecode,
      "flv_play_url" => "http://".$play_domain."/live/$livecode.flv",
      "m3u8_play_url" => "http://".$play_domain."/live/$livecode.m3u8",
    ];
    return $url;
  }
}

给安卓ios配置许可证

到此这篇关于php和腾讯直播的实现代码的文章就介绍到这了,更多相关php和腾讯直播内容请搜索搞代码以前的文章或继续浏览下面的相关文章希望大家以后多多支持搞代码


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php和腾讯直播的实现代码
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址