php教程

抖音无水印解析PHP接口代码分享

我的站长站 2024-09-23 人阅读

接口源码说明

抖音无水印解析PHP接口代码,如果首次解析不出来,就需要手动访问一次抖音视频地址(如:https://v.douyin.com/ihWf6mpq/),访问加载完成后,再次尝试解析即可成功。

接口代码

<?php
 
//抖音无水印PHP版
//调用示例  http://localhost/?url=https://v.douyin.com/ihWf6mpq/
error_reporting(0);
$headers = get_redirect_url($_GET["url"]);
preg_match('|video/(.*?)/|',$headers, $a);
$targetUrl = 'https://www.douyin.com/user/self?modal_id='.$a[1].'&showTab=like';
$customUserAgent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36';
$result = fetchDataWithCustomUA($targetUrl, $customUserAgent);
preg_match('|<script id="RENDER_DATA" type="application/json">(.*?)</script>|',$result, $matches);
$middle_text = $matches[1];
$m =json_decode(Urldecode($middle_text));
$arr = array('名字' => $m->app->videoDetail->shareInfo->shareLinkDesc, '封面' =>"https:".$m->app->videoDetail->video->originCover, '视频' =>"https:".$m->app->videoDetail->video->playAddr[0]->src, 'MP3' =>$m->app->videoDetail->music->playUrl->uri);
echo stripslashes(json_encode($arr,JSON_UNESCAPED_UNICODE));
   
function fetchDataWithCustomUA($url, $customUA) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_USERAGENT, $customUA);
    curl_setopt ($ch, CURLOPT_COOKIE , 'ttwid=1%7CP3XfP8WLdGrhhniqvZgITdxee4ylTHNIAFxiA8uiudk%7C1692861969%7Ccbc1e8cb639b9f2537017019cf2e16034eb5e02f91317cf02da669c3d9035225; douyin.com; device_web_cpu_core=8; device_web_memory_size=8; webcast_local_quality=null; strategyABtestKey=%221692861971.054%22; passport_csrf_token=52d1b9f0bdc601061b35649f820990a7; passport_csrf_token_default=52d1b9f0bdc601061b35649f820990a7; FORCE_LOGIN=%7B%22videoConsumedRemainSeconds%22%3A180%7D; s_v_web_id=verify_lloub543_MIbxaeCL_vWX9_4eQ5_B6rZ_XiLUd8TiC2z5; volume_info=%7B%22isUserMute%22%3Afalse%2C%22isMute%22%3Afalse%2C%22volume%22%3A0.5%7D; csrf_session_id=b3e96aad3d33a588099da1957c61412b; bd_ticket_guard_client_data=eyJiZC10aWNrZXQtZ3VhcmQtdmVyc2lvbiI6MiwiYmQtdGlja2V0LWd1YXJkLWl0ZXJhdGlvbi12ZXJzaW9uIjoxLCJiZC10aWNrZXQtZ3VhcmQtcmVlLXB1YmxpYy1rZXkiOiJCR1QzbVlJN1JlQ1pHYjRyMUxyREJMNWVqVHA5SWJxdjFPZHdsK08rNWFsRFY2dzFFSWZTVEpUbGppeE9GMW9ZK05ubFExbzIwU1Y4UWtUd3gxYUo3aUE9IiwiYmQtdGlja2V0LWd1YXJkLXdlYi12ZXJzaW9uIjoxfQ==; ttcid=6e2c49249e684b31adc93ec9d811921d35; pwa2=%220%7C0%7C2%7C0%22; __ac_nonce=064e715db00dce12044ad; __ac_signature=_02B4Z6wo00f01JFEgwQAAIDBX8zLRARkI5yRZIeAAEC64rwojdCoEppcamcP.zNDFFTvK-IdW9t65-J9QZ6AQspB6MmaGXcO2csLGYi13EYeG3xUA6EfUKHORVbG8tX9TWqmvF-XXQJq1BC37e; tt_scid=0RB0BQpAJZCtDUGQEfvGfovmjxWL4NUYr7faECJEqAxGXeNJ7oGESHkuMx8zXBOuf02f; download_guide=%223%2F20230824%2F0%22; IsDouyinActive=true; stream_recommend_feed_params=%22%7B%5C%22cookie_enabled%5C%22%3Atrue%2C%5C%22screen_width%5C%22%3A1920%2C%5C%22screen_height%5C%22%3A1080%2C%5C%22browser_online%5C%22%3Atrue%2C%5C%22cpu_core_num%5C%22%3A8%2C%5C%22device_memory%5C%22%3A8%2C%5C%22downlink%5C%22%3A5.95%2C%5C%22effective_type%5C%22%3A%5C%224g%5C%22%2C%5C%22round_trip_time%5C%22%3A50%7D%22; VIDEO_FILTER_MEMO_SELECT=%7B%22expireTime%22%3A1693470886177%2C%22type%22%3Anull%7D; home_can_add_dy_2_desktop=%221%22; msToken=phFAWMM1fxkFc4oj6QE8_DMbU57I87HDv_NnoZ9uVNGkx1j9HDT-ddGbno81zAHZuXDF4OKjA1mHIchWdQYixYfFkSCi1Kb-1dKKjmHw_yz-YTa2wQ==; msToken=f_v0fvPvEDKoOBgIkJwOciMoWbigmQ0oZzhY2RgQfO2Otc1zIwtEkRE_kmn8FYYdXDQjAa0tfamm7kXHYD_1M3VrLvLvfQaIP2XtKctXHG4WNcKRyw==; xgplayer_user_id=180566107648');
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
function get_redirect_url($url){
$header = get_headers($url, 1);
if (strpos($header[0], '301') !== false || strpos($header[0], '302') !== false) {
if(is_array($header['Location'])) {
return $header['Location'][count($header['Location'])-1];
}else{
return $header['Location'];
}
}else {
return $url;
}
}
?>

使用方法

1、复制上面代码保存到index.php

2、浏览器访问:http://localhost/index.php?url=https://v.douyin.com/ihWf6mpq/,后面的为需要解析的抖音视频地址,自行替换。

返回格式:

{"名字":"2.07 10/20 N@w.Fu Cuf:/ 经典老歌就是好听《劲爆DJ版串烧56分钟》首首劲爆动感十足# 女dj # 车载dj音乐 # 车载音乐u盘 # dj舞曲 # 车载电音 # dj小姐姐 # dj # 劲爆dj # 车载 # dj音乐 %s 复制此链接,打开Dou音搜索,直接观看视频!","封面":"https://p9-pc-sign.douyinpic.com/tos-cn-p-0026/bfbb6755bbe549ffbb2b571351963265_1688428980~tplv-dy-360p.jpeg?biz_tag=pcweb_cover&from=327834062&s=PackSourceEnum_AWEME_DETAIL&sc=origin_cover&se=false&x-expires=1728259200&x-signature=QJ1%2Fy3Y2tT8Ptt%2FmOX025rdC6L0%3D","视频":"https://v26-web.douyinvod.com/386e8a0bd0d4425329e8d330f6b57208/66f0f0e3/video/tos/cn/tos-cn-ve-15c001-alinc2/oAWB3SFRwIDZkygAVgSAfeEqJmEu7gYBEB2fzC/?a=6383&br=3235&bt=3235&btag=c0000e00038000&cd=0%7C0%7C0%7C3&ch=26&cquery=100w_100B_100D_100J_100o&cr=3&cs=0&cv=1&dr=0&ds=4&dy_q=1727052205&feature_id=f0150a16a324336cda5d6dd0b69ed299&ft=AJkeU_TERR0sTHC4NDv2Nc0iPMgzbL3R7RsU_4Mu5SiJNv7TGW&is_ssr=1&l=202409230843259313E0B3BBA0C953A2D5&lr=all&mime_type=video_mp4&qs=0&rc=N2RkOjQ8Z2Y8OWVkNGdkZkBpM2o2cXM5cnN5bDMzNGkzM0AzMzM1MC4zNTUxMDJfYC5jYSNkY2deMmQ0XmVgLS1kLS9zcw%3D%3D","MP3":null}


相关专题
解析
解析
2022-03-03 1460

解析是一种破解限制下载工具,我的站长站为你整理收集所有关于解析的资源,包含视频解析软件,音乐解析软件,在线解析网站,通通都是免费解析下载必备软件....

相关推荐
  • 抖音去水印
  • 无水印解析
  • 解析接口
  • PHP抖音视频无水印解析接口

    php无水印解析抖音视频接口,直接返回抖音视频链接地址。<?phpheader("Content-Type: text/html;charset=utf-8");//设置编码error_reporting (E_ALL & ~E_NOTICE);$url = $_GET[&#39;url&#39;];if (empty($_GET[&#39;url&#39;]) || !isset($_GET[&#39...

    php教程 281 4年前
  • 网易云音乐一句话免费解析下载

    我的站长站分享过很多网易云解析下载工具。[xxid]46,307[/xxid]今天分享这篇更简单,只需一个链接。网易云解析接口http://music.163.com/song/media/outer/url?id=.mp3使用方法比如我们打开这篇歌曲:https://music.163.com/#/song?id=501220770我们把...

    经验分享 306 4年前
  • 分享一个苹果CMS可用P2P的M3U8解析代码

    苹果CMS可用P2P的M3U8解析代码,非CDNbye的P2P。<?php/** * @代码开源,透明,请勿用于商业用途,完全开源模式,供大家一起探讨研究 * @支持全网(支持跨域)的M3U8资源加速 * @调用举例:http://域名/m3u8.php?url= * @举例说明:https://www.xmaocloud.com/p2p.php?...

    苹果cms教程 612 4年前
最新更新