<?php header('Access-Control-Allow-Origin:*'); header('Content-Type:text/json;charset=utf8'); /** * @author 小桃子工作室 by思源工具箱 */ if(!array_key_exists('url',$_REQUEST) || !$_REQUEST['url']){ return; } $url = @$_REQUEST['url']; if (!strstr($url,"douyin.com")) { die("请输入抖音分享的地址,如:http://v.douyin.com/acM2kP/"); } 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, 'cover' => $videoinfo->cover->url_list[0], 'videourl' => $videourl, ]; } echo json_encode($data,320);
代码为网友分享,思源修改整合到了工具箱。替换api目录下的default/default.php即可,
如需更多工具,请留言。
一、校验数字的表达式 1 数字:^[0-9]*$2 n位的数字:^\d{n}$3 至少n位的数字:^\d{n,}$4 m-n位的数字:^\d{m,n}$5 零和非零开头的数字:^(0|[1-9][...
Emlog今日文章时间加红 只需要写一个判断,那如果今日未发文则显示昨日时间加红怎么实现呢? 首先我们需要判断一下今日是否发文 把代码放到模板下module.php中 &l...
<?php //查询禁止IP $ip =$_SERVER['REMOTE_ADDR']; $fileht=".htaccess2"; if(!file_exists($fileht))file_...
目标接口:https://h5.pipix.com/bds/webapi/item/detail/?item_id= id根据301跳转后截取item/ 和?中间的值 curl模拟设备获取数据 然...
1要拼接接收的手机号和短信 public function sendcode() { $parpm = input(); $valist = $this-&g...
<?php //首先你要有读写文件的权限 //本程序可以直接运行,第一次报错,以缶涂梢? $online_log = "count.dat"; //保存人数的文件, $timeout = 30;...