欢迎您光临自学哈网,只为分享网络知识教程,供大家学习参考!

「自学哈网」最新PHP解析抖音方法

作者 : 自学哈 本文共2213个字,预计阅读时间需要6分钟 2022-10-8 共185人阅读
也想出现在这里? 联系我们

最新PHP解析抖音方法,大家低调使用,就怕人家又换接口了,上代码!

$receive_data='https://v.douyin.com/******/';//这里换成你的链接
$receive_header=$_SERVER['HTTP_USER_AGENT'];
 
//判断url参数有没有编码
$shareUrl=is_url_decode($receive_data);
//获取视频详情页信息
$shareUrl_href = get_content_url($shareUrl);
preg_match('/href="(.*?)">Found/', $shareUrl_href, $videoUrl);
$videoUrl=$videoUrl[1];
//获取页面ID
$itemId=getSubstr($videoUrl, "video/", "/?");
$apiUrl = "https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=".$itemId;
$content = json_decode(get_content_url($apiUrl),true);
$video_data=get_content_url(str_replace("playwm","play",$content['item_list'][0]['video']['play_addr']['url_list'][0]),$receive_header);
preg_match('/<a href="(.*?)">Found/', $video_data, $videos_video);
$result_data=[
    'title'=>$content['item_list'][0]['desc'],
    'music'=>[
        'title'=>$content['item_list'][0]['music']['title'],
        'author'=>$content['item_list'][0]['music']['author'],
        'cover'=>$content['item_list'][0]['music']['cover_large']['url_list'][0],
        'audio'=>$content['item_list'][0]['music']['play_url']['uri']
    ],
    'author'=>[
        'nickname'=>$content['item_list'][0]['author']['nickname'],
        'signature'=>$content['item_list'][0]['author']['signature'],
        'avatar'=>$content['item_list'][0]['author']['avatar_larger']['url_list'][0]
    ],
    'videos'=>[
        'cover'=>$content['item_list'][0]['video']['cover']['url_list'][0],
        'ratio'=>$content['item_list'][0]['video']['ratio'],
        'video'=>$videos_video[1]
    ],
    'shareUrl'=>$shareUrl
];
return $result_data;
//或
//print_r($result_data);

注意:最好是手机端调用这个接口,并且header中的HTTP_USER_AGENT最好是你当前访问的header,否则视频还是有水印,并且还会无法播放

相关专题

本站声明:
本站所有资源来源于网络,分享目的仅供大家学习和交流!如若本站内容侵犯了原著者的合法权益,可联系邮箱976157886@qq.com进行删除。
自学哈专注于免费提供最新的分享知识、网络教程、网络技术的资源分享平台,好资源不私藏,大家一起分享!

自学哈网 » 「自学哈网」最新PHP解析抖音方法
也想出现在这里? 联系我们
© 2022 Theme by - 自学哈网 & WordPress Theme. All rights reserved 浙ICP备2022016594号