美高梅4858-美高梅4858mgm-[官方网站]

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

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

我已经部署好的(我自己做了改动):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://v5-dy.ixigua.com/0cdda091045c66f99f261844772abf9d/5e4773a0/video/tos/hxsy/tos-hxsy-ve-0015/7a26bfc1603340cd981e76bca7906a91/?a=1128&br=0&bt=507&cr=0&cs=0&dr=0&ds=6&er=&l=2020021511290501001203410423F11F5A&lr=&qs=0&rc=amx2c2RzNXlvczMzOmkzM0ApaTNnOWkzZGQ5NzM5OWc6M2dxXzAvNl4wZjBfLS0xLS9zcy9gYy1iMi82YTUwYDReYjA6Yw%3D%3D&vl=&vr="
  }
}

PHP 代码:

<?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 =@$_REQUEST;
preg_match("/http:\/\/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 (苹果; CPU 苹果 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(!@$res[0][1] || !@$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));

如无特别声明,该文章均为 美高梅4858官方网站NowTime.cc)原创,转载请遵循 署名-非商业性使用 4.0 国际(CC BY-NC 4.0) 协议,即转载请注明文章来源。


标签: none

赞 (2)

添加新评论

XML 地图 | Sitemap 地图