php抖音无水印视频获取代码


# 方法1和2取一种即可

<?php header("Access-Control-Allow-Origin: *");//允许所有地址跨域请求
//使用方法1(url接收抖音复制链接后的大段文字,自动提取链接)推荐
    $url = $_POST['url']; 
preg_match_all('/https:\/\/[A-Za-z0-9_.\/]+(\s?)/', $url,$arr);//获取url以空格结尾
$yurl = $arr[0][0];
-------------------------------------------------------------------------------------
//使用方法2 (直接传url为复制链接内的地址即可,如https://v.douyin.com/RbtKWjm/)
$yurl = $_POST['url'];
-------------------------------------------------------------------------------------
//下面代码公用 $res = qqxz_http_get($yurl); preg_match('/href="(.*?)">Found/', $res, $matches); $linkid = substr(str_replace('&', '&', $matches[1]),38,19); // preg_match('/itemId: "(.*?)",/', qqxz_http_get(str_replace('&', '&', $matches[1])), $matches); $arr = json_decode(qqxz_http_get('https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids='. $linkid), true); $url = $arr['item_list'][0]["video"]["play_addr"]["url_list"][0]; include('dy2.html'); function qqxz_http_get($url) { $Header=array( "User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1"); $con=curl_init((string)$url); curl_setopt($con,CURLOPT_HEADER,False); curl_setopt($con,CURLOPT_SSL_VERIFYPEER,False); curl_setopt($con,CURLOPT_RETURNTRANSFER,true); curl_setopt($con,CURLOPT_HTTPHEADER,$Header); curl_setopt($con,CURLOPT_TIMEOUT,5000); $result = curl_exec($con); return $result; } ?>

截止发文,亲测可用。

上一篇:PHP对接环信im


下一篇:PHP的curl有三种请求数据的方式你需要知道raw、form-data、x-www-form-urlencoded