技术文摘

使用PHP解析抖音无水印视频的方法

作者:雨祺   发表于:
浏览:1197次    字数:4085  原创
级别: 站长   总稿: 69 篇,  月稿: 0
每天都能看到4414站长论坛发关于抖音视频的!那我们现在来一波用自己的服务器解析抖音的无水印视频!(需要服务器上面有PHP环境)

使用第三方库:安装FFmpeg:在轻量云上安装FFmpeg库。可以通过在终端中执行相应的命令来安装FFmpeg,具体命令可能因云服务商的不同而有所变化。此方法不在讲解的范围内!命令多了都把老坛们搞晕乎了!!!接下来讲解用纯PHP解析抖音无水印视频。

使用方法与百度上面那些失效的教程一模一样:

在php后加上 ?url= 抖音的分享url 。比如本站的接口地址
  1. https://www.meiweny.cn/ecmsapi/index.php?mod=jiexi&act=douyin&url=https://v.douyin.com/iR7kXs5D/ 
输出仍然是JSON格式,这是当前最流行!没有办法!(毕竟web网站,小程序,APP都能接收JSON格式的数据)

以本站的API接口为例!输出的截图如下:(获取抖音视频的各种元数据,包括作者、抖音ID、点赞数、发布时间、视频标题、视频封面和无水印链接等。)



干货马上来了。注意:此代码已经自带Cookie值,如使用失效,请确保在 SendGetData 函数中添加自己的Cookie值。代码如下:
  1. <?php 
  2. header("Content-Type:application/json;charset=utf-8"); 
  3. header('Access-Control-Allow-Origin: *'); 
  4. // 禁止用户直接访问口文件 
  5. defined("ECMSAPI_MOD") or exit;  
  6. $url = @$_GET['url']?$_GET['url']:"https://v.douyin.com/iR7kXs5D/"
  7. function douyinjiexi($url){ 
  8. global $empire,$public_r,$dbtbpre;   
  9. if(empty($url)){ 
  10. $content = [ 
  11. 'status' => 203, 
  12. 'msg' => "请输入待解析的抖音链接"
  13. 'api_source' => "".$public_r['sitename']."官网地址:".$public_r['add_pcurl']."" 
  14. ]; 
  15. $Json=json_encode($content,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE); 
  16. echo stripslashes($Json); 
  17. exit(); 
  18. }else
  19. $ReturnLocationUrl = locationurl($url); 
  20. preg_match('/[0-9]+/', $ReturnLocationUrl, $id); 
  21. if (empty($id)) { 
  22. preg_match('/[0-9]+/', $url, $id); 
  23. $id = $id[0]; 
  24. $LocationReal = "https://www.douyin.com/aweme/v1/web/aweme/detail/?device_platform=webapp&aid=6383&channel=channel_pc_web&aweme_id=$id&pc_client_type=1&version_code=190500&version_name=19.5.0&cookie_enabled=true&screen_width=1344&screen_height=756&browser_language=zh-CN&browser_platform=Win32&browser_name=Firefox&browser_version=110.0&browser_online=true&engine_name=Gecko&engine_version=109.0&os_name=Windows&os_version=10&cpu_core_num=16&device_memory=&platform=PC&webid=7158288523463362079&msToken=abL8SeUTPa9-EToD8qfC7toScSADxpg6yLh2dbNcpWHzE0bT04txM_4UwquIcRvkRb9IU8sifwgM1Kwf1Lsld81o9Irt2_yNyUbbQPSUO8EfVlZJ_78FckDFnwVBVUVK"
  25. $Post_Data = [ 
  26. 'url' => $LocationReal, 
  27. 'user_agent' => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Postman/10.16.0 Chrome/100.0.4896.160 Electron/18.3.5 Safari/537.36" 
  28. ]; 
  29. $jsonStr = json_encode($Post_Data); 
  30. $ResultXBugUrl = json_decode(SendJsonPostData($jsonStr),true)['param']; 
  31. $ResultData = SendGetData($ResultXBugUrl); 
  32. $JsonResult = json_decode($ResultData,true); 
  33. $video_url = $JsonResult['aweme_detail']['video']['play_addr']['url_list'][0]; 
  34. if(empty($video_url)){ 
  35. $content = [ 
  36. 'status' => 201, 
  37. 'msg' => "视频解析失败"
  38. 'api_source' => "".$public_r['sitename']."官网地址:".$public_r['add_pcurl']."" 
  39. ]; 
  40. $Json=json_encode($content,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE); 
  41. echo stripslashes($Json); 
  42. exit(); 
  43. }else
  44. $content = [ 
  45. 'status' => 200, 
  46. 'msg' => "解析成功"
  47. 'videourl' => $JsonResult['aweme_detail']['video']['play_addr']['url_list'][0], 
  48. 'data' => [ 
  49. 'url' => "分享地址:".$url,    
  50. 'author' => $JsonResult['aweme_detail']['author']['nickname'], 
  51. 'uid' => $JsonResult['aweme_detail']['author']['unique_id'],  
  52. 'like' => $JsonResult['aweme_detail']['statistics']['digg_count'],  
  53. 'time' => $JsonResult['aweme_detail']["create_time"],  
  54. 'title' => $JsonResult['aweme_detail']['desc'], 
  55. 'cover' => $JsonResult['aweme_detail']['video']['origin_cover']['url_list'][0], 
  56. 'jiexiurl' => $JsonResult['aweme_detail']['video']['play_addr']['url_list'][0] 
  57. ], 
  58. 'api_source' => "".$public_r['sitename']."官网地址:".$public_r['add_pcurl']."" 
  59. ]; 
  60. $Json=json_encode($content,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE); 
  61. echo stripslashes($Json); 
  62. exit(); 
  63. function SendJsonPostData($jsonStr){ 
  64. global $empire,$public_r,$dbtbpre;   
  65. $ch = curl_init(); 
  66. curl_setopt($ch, CURLOPT_POST, 1); 
  67. curl_setopt($ch, CURLOPT_URL, "https://tiktok.iculture.cc/X-Bogus"); 
  68. curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr); 
  69. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0"); 
  70. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
  71. curl_setopt($ch, CURLOPT_HTTPHEADER, [ 
  72. "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"
  73. "Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"
  74. "Content-Type:application/json;charset=utf-8"
  75. "Connection: keep-alive" 
  76. ]); 
  77. curl_setopt($ch, CURLOPT_ENCODING, ''); 
  78. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
  79. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
  80. $result = curl_exec($ch); 
  81. if (curl_errno($ch)) { 
  82. $content = [ 
  83. 'code' => 500, 
  84. 'msg' => "访问出错"
  85. 'api_source' => "".$public_r['sitename']."官网地址:".$public_r['add_pcurl']."" 
  86. ]; 
  87. $Json=json_encode($content,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE); 
  88. echo stripslashes($Json); 
  89. exit(); 
  90. curl_close($ch); 
  91. return $result; 
  92. function SendGetData($url){ 
  93. global $empire,$public_r,$dbtbpre;   
  94. $ch = curl_init(); 
  95. curl_setopt($ch,CURLOPT_URL,$url); 
  96. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
  97. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
  98. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Postman/10.16.0 Chrome/100.0.4896.160 Electron/18.3.5 Safari/537.36"); 
  99. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
  100. curl_setopt($ch, CURLOPT_HTTPHEADER, [ 
  101. "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"
  102. "Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2"
  103. "Referer: https://www.douyin.com/"
  104. "Connection: keep-alive"
  105. "Cookie: ttwid=1%7C0YBAnAwiC5T3U5yJi8RVXEK3DOwF_2vpJ7kVJJZe8HU%7C1666668932%7C21048e6555b73e8801d3956afc6130b4a05ae73a2eefe4d3fef5ef1b61caf0e9; __live_version__=%221.1.1.2586%22; odin_tt=a77b90afad5db31e86fe004b39c5f35423292023ce7837cde82fd1f7fe54278890ce24dc89e09c8a2e55b1f4904950a7b0fca6b4fbff3b549ba6d55a335373ec; pwa2=%223%7C0%7C0%7C0%22; s_v_web_id=verify_lkagpdq1_IuHpxJyS_q6YH_4AvH_8aNH_zhvGPr95Jrc8; passport_csrf_token=301cf539fb735ab77de7e382b0dd93e5; passport_csrf_token_default=301cf539fb735ab77de7e382b0dd93e5; bd_ticket_guard_client_data=eyJiZC10aWNrZXQtZ3VhcmQtdmVyc2lvbiI6MiwiYmQtdGlja2V0LWd1YXJkLWl0ZXJhdGlvbi12ZXJzaW9uIjoxLCJiZC10aWNrZXQtZ3VhcmQtcmVlLXB1YmxpYy1rZXkiOiJCRXhuWUdqREVBa3ErdjRsT2l3anRIWi9HU2hRNXFseWdJMklLanIxM0orRHozYnA0M2pXc3M3N25CUzdnbE5tTXhHbWU3cldoSE9pdkJvVmNnT2JiWFU9IiwiYmQtdGlja2V0LWd1YXJkLXdlYi12ZXJzaW9uIjoxfQ==; passport_assist_user=CkHJzB17Xsy3FUHyNfX2Dyb8IFKKA_0pu1SKYG0OAT_av3ImQyCbEmGJV7b8MJep4l9MjeCRK1FPY9k9yAkVHbIbvhpICjzS68aPlRjIsUzHLIEM-5jMbp9awcdJnkACni5Nnc_PBm4ljAlEqChbF4nYPpn4xyh4kY2hBvRikmXs0sgQ4fq2DRiJr9ZUIgEDbm8-yw%3D%3D; n_mh=13KNPUKNEzoW3A4J-OLRxfal2zj1GbF-vJUFPs3WSIY; sso_uid_tt=2581aab41d03156c0b7fee9c7e865c6c; sso_uid_tt_ss=2581aab41d03156c0b7fee9c7e865c6c; toutiao_sso_user=b2556b53ed5cee89e947b154b17645f1; toutiao_sso_user_ss=b2556b53ed5cee89e947b154b17645f1; sid_ucp_sso_v1=1.0.0-KDhlZjRhMmJhZGU0OTVmOWM0YzBkMTY5ZGNkZmI4NTFjNTk2ODU5OTkKHwiPluCxqYzbAhC29OKmBhjvMSAMMLDIpZkGOAZA9AcaAmhsIiBiMjU1NmI1M2VkNWNlZTg5ZTk0N2IxNTRiMTc2NDVmMQ; ssid_ucp_sso_v1=1.0.0-KDhlZjRhMmJhZGU0OTVmOWM0YzBkMTY5ZGNkZmI4NTFjNTk2ODU5OTkKHwiPluCxqYzbAhC29OKmBhjvMSAMMLDIpZkGOAZA9AcaAmhsIiBiMjU1NmI1M2VkNWNlZTg5ZTk0N2IxNTRiMTc2NDVmMQ; sid_guard=c1d1ac1d22198149dfc6cac74938b14a%7C1691925046%7C5184000%7CThu%2C+12-Oct-2023+11%3A10%3A46+GMT; uid_tt=7e39a426dac7802b2448fa2266ca1b85; uid_tt_ss=7e39a426dac7802b2448fa2266ca1b85; sid_tt=c1d1ac1d22198149dfc6cac74938b14a; sessionid=c1d1ac1d22198149dfc6cac74938b14a; sessionid_ss=c1d1ac1d22198149dfc6cac74938b14a; sid_ucp_v1=1.0.0-KDc4Y2VkZjIyN2JlMDNhYmNhYTFlYTE5ODM1YzI2YjVlZDNmMGY0N2YKGwiPluCxqYzbAhC29OKmBhjvMSAMOAZA9AdIBBoCbHEiIGMxZDFhYzFkMjIxOTgxNDlkZmM2Y2FjNzQ5MzhiMTRh; ssid_ucp_v1=1.0.0-KDc4Y2VkZjIyN2JlMDNhYmNhYTFlYTE5ODM1YzI2YjVlZDNmMGY0N2YKGwiPluCxqYzbAhC29OKmBhjvMSAMOAZA9AdIBBoCbHEiIGMxZDFhYzFkMjIxOTgxNDlkZmM2Y2FjNzQ5MzhiMTRh; LOGIN_STATUS=1; _bd_ticket_crypt_cookie=861cdca903469f36dd23fc1ecfe847c1; __security_server_data_status=1; store-region=us; store-region-src=uid; d_ticket=28acd5a9c6df4227b13582669694acded6ede; __ac_nonce=064ec4f3a00901157c769; __ac_signature=_02B4Z6wo00f01ve8HKgAAIDD6.-iFWbfM-r3jRgAANkQTCm7UjsJOQlMGY7o-iPsCIAe0kuriDaQ15lHcML.nW.cGNWpSBLUJzdr6s8KHRbqh5ywvupCeAKBEHKKbji7hD1-Z0x3DI-n0KKx34; douyin.com; device_web_cpu_core=16; device_web_memory_size=-1; webcast_local_quality=null; publish_badge_show_info=%220%2C0%2C0%2C1693208382348%22; IsDouyinActive=true; home_can_add_dy_2_desktop=%220%22; strategyABtestKey=%221693208382.387%22; stream_recommend_feed_params=%22%7B%5C%22cookie_enabled%5C%22%3Atrue%2C%5C%22screen_width%5C%22%3A1344%2C%5C%22screen_height%5C%22%3A756%2C%5C%22browser_online%5C%22%3Atrue%2C%5C%22cpu_core_num%5C%22%3A16%2C%5C%22device_memory%5C%22%3A0%2C%5C%22downlink%5C%22%3A%5C%22%5C%22%2C%5C%22effective_type%5C%22%3A%5C%22%5C%22%2C%5C%22round_trip_time%5C%22%3A0%7D%22; VIDEO_FILTER_MEMO_SELECT=%7B%22expireTime%22%3A1693813183367%2C%22type%22%3A1%7D; volume_info=%7B%22isUserMute%22%3Afalse%2C%22isMute%22%3Atrue%2C%22volume%22%3A1%7D; my_rd=1; passport_fe_beating_status=true; msToken=ESPx4FwNhcdEvr36-bmhWde9xupU_c64WeeqvvzqzLCtmEsvGPXhkwsKM8miaoC2w8gWSzNAfqxPEju4w3jzopIFompVSmwemq9-z1F8V-2vLNhTxLlYCUVdXkzNj6zM; download_guide=%221%2F20230828%2F0%22; csrf_session_id=3c194edf7f2cee968b0df65f97a11648; msToken=XFIGWeX20IGrrEUGYr_4SR2DPrduwK5zxB3gOp8FfbxW_Ng-w9uNh8wQRUIoPUtkSblL6msqte55jyfcrKPb8eDZekS9Q1P9hkdkPFiV4Ni-l9Vmsr0KgFo5MOkLaBZy; tt_scid=-i-7N5fAMRj8pGg4drGXbjasutdtD4tzIeqRnm6OJ1LoXRRZGl8FNhORnEuY3id.b3b7" 
  106. ]); 
  107. $result = curl_exec($ch); 
  108. if (curl_errno($ch)) { 
  109. $content = [ 
  110. 'code' => 500, 
  111. 'msg' => "访问出错"
  112. 'api_source' => "".$public_r['sitename']."官网地址:".$public_r['add_pcurl']."" 
  113. ]; 
  114. $Json=json_encode($content,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE); 
  115. echo stripslashes($Json); 
  116. exit(); 
  117. curl_close($ch); 
  118. return $result; 
  119. function locationurl($url){ 
  120. $ch = curl_init(); 
  121. curl_setopt($ch, CURLOPT_URL, $url); 
  122. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
  123. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
  124. $res = curl_exec($ch); 
  125. $final_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); 
  126. curl_close($ch); 
  127. return $final_url; 
  128. echo douyinjiexi($url); 
此种开发逻辑可以做聚合万能短视频解析平台(皮皮虾,抖音,快手,哔哩哔哩,虎牙视频,懂车帝,火山,皮皮虾,皮皮搞笑,最左,小影,趣头条,微博,迅雷,美图秀秀,秒拍,美拍,京东,淘宝,天猫,拼多多....) 还支持海外平台一键解析...

声明:此解析教程不能保证永久有效!只能在当前时间到未来不确定时间段是可以用的是有效的!毕竟资源都是别人的!说得难听点就是窃取别人的资源!别人只要稍微改下规则就失效了!不过有点PHP基础的是很容易修改的!此代码逻辑毕竟清晰!如果是帝国CMS的话且安装了万能API插件的!复制过去直接可以用!如果不是请把全局变量修改为你自己的!!!

帝国CMS万能API接口下载地址:
  1. https://www.meiweny.cn/ruanjianleyuan/2.html 

【审核人:站长】

收藏   加好友   生成海报   分享
点赞(0)
打赏
Tags: PHP 视频 使用 方法 解析 水印

发布者资料

热门文章

技术文摘

查看更多技术文摘
首页
栏目
搜索
会员
投稿