骑士云主机西部数码代理商,空间域名低价销售
一个分享WordPress、Zblog、Emlog、Typecho等主流博客的教程网站!
当前位置:网站首页 > 其他相关教程 > 正文

抖音去水印小程序服务器端PHP源码

作者:xlnxin发布时间:2022-10-02分类:其他相关教程浏览:80


导读:<?php$url=$_GET['url'];//获取视频url$url=get_redirect_url($url);//获取视频ID$str=...

<?php

$url = $_GET['url'];

//获取视频url

$url = get_redirect_url($url);

//获取视频ID

$str = dirname($url);

$id = substr($str,strripos($str,'video')+6);

//调用抖音官方API

$str = file_get_contents('https://www.douyin.com/web/api/v2/aweme/iteminfo/?item_ids='.$id);

//将返回的json数据转为数组

$data = json_decode($str,true);

//获取有水印的视频地址

$url = $data['item_list'][0]['video']['play_addr']['url_list'][0];

//将playvm替换为play,从而获取无水印的视频地址

$url = str_replace('playwm','play',$url);

//获取重定向后的真实地址

$video_url = get_redirect_url($url);

echo "<a href='$video_url' target='_blank'>$video_url</a>";


function get_redirect_url($url) {

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(

'Accept: */*',

'Accept-Encoding: gzip',

'Connection: Keep-Alive',

'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'

));

curl_setopt($ch, CURLOPT_HEADER, true);

curl_setopt($ch, CURLOPT_NOBODY, 1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$ret = curl_exec($ch);

curl_close($ch);

preg_match("/Location: (.*?)\r\n/iU",$ret,$location);

return $location[1];

}


标签:服务器程序小程序