2019最新抖音無水印解析接口源碼

發布日期:2019-10-01 19:44:10 作者:何以往事

  • 正文內容
  • 相關推薦

之前分享過抖音無水印解析源碼,這次發一個接口,可以自己搭建。

代碼內容:


<?php
header('Access-Control-Allow-Origin:*');
header('Content-Type:text/json;charset=utf8');

/**
 * 夢城博客-dcqzz.cn
 */

if(!array_key_exists('url',$_REQUEST) || !$_REQUEST['url']){
	return;
}
$url = @$_REQUEST['url'];

preg_match("/http:\/\/v.douyin.com\/\S+/",$url,$res);

function curl($url, $header, $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, $header);
	if($getinfo){
		curl_exec($ch);
		$data = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
	}else{
		$data = curl_exec($ch);
	}
    curl_close($ch);
    return $data;
}

$header = [
	'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 (!empty(strpos($url,"douyin"))) {
    $content = curl($res[0],$header);

preg_match_all("/itemId: \"([0-9]+)\"|dytk: \"(.*)\"/", $content, $res, PREG_SET_ORDER);

if(!$res[0][1] || !$res[1][2]){
	die("數據異常");
}
$itemId = $res[0][1];
$dytk = $res[1][2];

$api = "https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids={$itemId}&dytk={$dytk}";

$json = curl($api, $header);

$arr = json_decode($json);

$videoinfo = $arr->item_list[0]->video;

$videourl = curl($videoinfo->play_addr->url_list[0], $header, true);

$data = [
	'title'    => $arr->item_list[0]->desc,
	'img'      => $videoinfo->cover->url_list[0],
	'url' => $videourl, 
];
} else {
    $ch = curl_init();//初始化curl
    curl_setopt($ch, CURLOPT_URL,"http://www.kaolajiexi.com/api/apply/wb");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "pageUrl={$url}");
    $data = curl_exec($ch);//運行curl
    curl_close($ch);
    $res = json_decode($data,true);
    $data = [
        'title'    => $res["data"]["data"]["title"],
        'img'      => $res["data"]["data"]["coverUrls"][0],
        'url' => $res["data"]["data"]["videoUrls"][0],
    ];
}
echo json_encode($data,320);


調試方法:你的域名+接口名?url= 輸入地址

例如:https://api.dcqzz.cn/api/dy.php?url=

搜一下

頭像
描述: ? 我愿用一世陽光換你的微笑 ?

本文標簽:

文章標題:2019最新抖音無水印解析接口源碼

文章鏈接:http://www.xzhnfq.live/post/878

版權聲明:若無特殊注明,本文皆為 何以往事 原創,轉載請保留文章出處。

發表評論

電子郵件地址不會被公開。 必填項已用*標注

2987 多乐彩11选五开奖走势图