<?php

/**
 * 获取抖音无水印视频地址
 * @param string $url 抖音分享地址
 * @return json
 * @example 调用方法 例: echo douying('http://v.douyin.com/UyxaDa/');
 * @author Reaper <a@0oo.ren>
 * @request https://www.52bz.la
 */
 function douying($url){
    $content = curl($url)['content'];
    preg_match('/itemId: "(.*?)"/', $content, $itemId);
    preg_match('/dytk: "(.*?)"/', $content, $dytk);
    $url_data['itemId'] = $itemId[1];
    $url_data['dytk'] = $dytk[1];
    $content = curl('https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=' . $url_data['itemId'] . '&dytk=' . $url_data['dytk']);
    $json_data = json_decode($content['content'], 1)['item_list'][0]['video']['download_addr']['url_list'][rand(0, 1)];
    $file_url = curl($json_data)['url'];
    $data = ['code' => 200, 'msg' => '获取成功!', 'download' => $file_url];
    return json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);}
 function curl($url, $ref = 'https://www.iesdouyin.com/')
 {
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_REFERER, $ref);
    curl_setopt($ch, CURLOPT_USERAGENT, 'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4 (compatible; Baiduspider/2.0; +https://www.52bz.la)');
    $content = curl_exec($ch);
    $newurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
    curl_close($ch);
    return ['content' => $content, 'url' => $newurl];}







转载来源https://www.codedog.wang/4156.html


版权属于:苏安吖

本文链接:https://ipayy.net/web/91.html

转载时须注明出处及本声明

Last modification:September 23rd, 2020 at 08:29 pm
嘤嘤嘤,来打赏点吧ε٩(๑> ₃ <)۶ з