PHP随机输出视频API源码,php 32行代码简单实现抖音无水印视频api,附前台页面
[PHP] 純文本查看 復(fù)制代碼<?php
header("Content-Type: text/html;charset=utf-8");
if(isset($_GET["url"])){
//設(shè)置移動(dòng)端請(qǐng)求頭
$hdrs = array(
'http' =>array('header' =>
"Referer: [url=https://v.douyin.com/]https://v.douyin.com/[/url]" .
"User-Agent: Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Mobile Safari/537.36\r\n"
),
);
//設(shè)置請(qǐng)求頭
$context = stream_context_create($hdrs);
//通過(guò)請(qǐng)求獲得該視頻的id
file_get_contents($_GET["url"],0,$context);
$id=$http_response_header[6];
$id=explode("video/",$id);
$id=explode("/?",$id[1]);
$id=$id[0];
//通過(guò)接口獲得視頻的詳細(xì)內(nèi)容
$url="https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=".$id;
$jsonData=file_get_contents($url,0,$context);
$jsonData=json_decode($jsonData);
//獲取到視頻有水印的播放地址
$url=$jsonData->item_list[0]->video->play_addr->url_list[0];
//獲取到視頻無(wú)水印的播放地址
$url=str_replace("playwm","play",$url);
//獲取真實(shí)的視頻url
file_get_contents($url,0,$context);
for($i=0;$i
$url=$http_response_header[$i];
if(substr($url,0,8)=="location"){
$url=$http_response_header[$i];
break;
}
}
$url=str_replace("location: ","",$url);
echo $url;
}
總結(jié)
以上是生活随笔為你收集整理的PHP随机输出视频API源码,php 32行代码简单实现抖音无水印视频api,附前台页面的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: php self this static
- 下一篇: 炸金花 php算法,php 炸金花牌型