抖音短视频无水印解析接口源码

<?php
/**
 * 使用方法:?url=http://v.douyin.com/Ngon78/
 */
header("Content-Type: application/json");
$url = isset($_GET['url']) ? $_GET['url'] : die("参数不能为空");
$UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36";
$html = MloocCurlGet($url,true,$UserAgent);
preg_match('~video_id=(.*?)&line~', $html, $video_id);
preg_match('~cover: "(.*?)"~', $html, $cover);
if(!isset($video_id[1]) || !isset($cover[1])){
      $result['code'] = 400;
      $result['msg'] = "获取失败";
    exit(json_encode($result));
}
$video_id = trim($video_id[1]);
$cover = trim($cover[1]);

$html = MloocCurlGet("https://aweme.snssdk.com/aweme/v1/play/?video_id=$video_id");

preg_match('~Location: (.*?)\n~', $html, $location);
if(!isset($location[1])){
      $result['code'] = 400;
      $result['msg'] = "获取失败";
    exit(json_encode($result));
}
$location = trim($location[1]);
$result['code'] = 200;
$result['msg'] = "获取成功";
$result['playAddr'] = $location;
$result['cover'] = $cover;
exit(json_encode($result));

function MloocCurlGet($url, $idFllow=false, $UserAgent = '')
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    #关闭重定向
      if($idFllow){
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    }
      if($UserAgent){
        curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
    }
      
      curl_setopt($curl, CURLOPT_HEADER, 1);
      if($cookie!=""){
        curl_setopt($curl, CURLOPT_COOKIE, $cookie);
    }
  
    #关闭SSL
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    #返回数据不直接显示
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    $response = curl_exec($curl);
    curl_close($curl);
    return $response;
}

给TA打赏
共{{data.count}}人
人已打赏
源码分享

华数TV解析源码

2018-12-25 22:48:10

源码分享

皮皮虾短视频无水印解析源码

2019-1-24 23:59:26

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
有新私信 私信列表
搜索