PHP 解析抖音短视频无水印源码(非调用 Ta 人接口解析)

@Ta 02-27 10:23 1466点击

Gitee 地址(不是我写的):https://gitee.com/uxqq/dyapi

PHP 代码:

我已经部署好的(我自己做了改动):https://api.nowtime.cc/v1/douyin/videoParse?url=视频链接
例如:https://api.nowtime.cc/v1/douyin/videoParse?url=https://v.douyin.com/sD6Wyk
返回结果:

{
"code": 200,
"msg": "获取成功",
"data": {
"title": "马斯克Boring公司开发地下立体交通隧道,系统智能管理,将让无间隔跟车成为可能#马斯克 #boring隧道",
"img": "https://p9-dy.byteimg.com/img/tos-cn-p-0015/ec7c7768c516479489f8e6d62435bf95_1581734295~c5_300x400.jpeg?from=2563711402_large",
"videourl": "http://v26-dy.ixigua.com/faeb8cb648497eae7e9013e3cb229a0f/5e476f43/video/tos/hxsy/tos-hxsy-ve-0015/7a26bfc1603340cd981e76bca7906a91/?a=1128&br=0&bt=507&cr=0&cs=0&dr=0&ds=6&er=&l=202002151110280100080710881AFD39BC&lr=&qs=0&rc=amx2c2RzNXlvczMzOmkzM0ApaTNnOWkzZGQ5NzM5OWc6M2dxXzAvNl4wZjBfLS0xLS9zcy9gYy1iMi82YTUwYDReYjA6Yw%3D%3D&vl=&vr="
}
}
<?php
header('Access-Control-Allow-Origin:*');
header('Content-type:application/json; charset=utf-8');
error_reporting(0);
if(!array_key_exists('url',$_REQUEST))exit(error("缺少参数"));
$url [email protected]$_REQUEST;
preg_match("/v.douyin.com\/\S+/",$url['url'],$res);
if (!$res)exit(error("请检查你输入的链接"));
function error($str){
    return json_encode([
        "code"=>-1,
        "msg"=>$str
    ],JSON_UNESCAPED_UNICODE);
}
function curl($url, $getinfo=false)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_NOBODY, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, false);
    curl_setopt($ch, CURLOPT_TIMEOUT, 3600);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_ENCODING, '');
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'));
    if($getinfo){
        curl_exec($ch);
        $data = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
    }else{
        $data = curl_exec($ch);
    }
    curl_close($ch);
    return $data;
}
preg_match_all("/itemId: \"([0-9]+)\"|dytk: \"(.*)\"/", curl($res[0]), $res, PREG_SET_ORDER);
if([email protected]$res[0][1] || [email protected]$res[1][2])exit(error("数据异常"));
$arr = json_decode(curl("https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids={$res[0][1]}&dytk={$res[1][2]}"));
exit(json_encode([
    "code"=>1,
    "msg"=>"获取成功",
    "data"=>[
        'title'    => $arr->item_list[0]->desc,
        'img'      => $arr->item_list[0]->video->cover->url_list[0],
        'videourl' => curl($arr->item_list[0]->video->play_addr->url_list[0], true)
    ]
],JSON_UNESCAPED_UNICODE));

红米 Note4X 标配版(黑色)

回复列表(5)
添加新回复
回复需要登录

[聊天-此处没有老虎] 情醉中国风:Hello https://sqyai.chatbro.com/ Redmi K.O