最新PHP解析抖音方法

最新PHP解析抖音方法,大家低调使用,就怕人家又换接口了,上代码!$receive_data='https://v.douyin.com/******/';//这里换成你的链接
$receive_header=$_SERVER['HTTP_USER_AGENT'];

[时间:04-16]    [浏览:]    [放入收藏夹]    [查看详情]

最新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,否则视频还是有水印,并且还会无法播放


  本文转载自:精准像素:11px.cn ,感谢作者分享实用知识


标签: