1

我正在使用两个功能来获取 url 或视频播放 1. 用于提取带有水印的视频的 tiktok

public function getDetails()
{
    $url = $this->url;
    $resp = $this->getContent($url);
    $check = explode("\"contentUrl\":\"", $resp);
    if (count($check) > 1) {
        $video = explode("\"", $check[1])[0];
        $videoWithoutWaterMark = $this->WithoutWatermark($url);
        $thumb = explode("\"", explode("\"thumbnailUrl\":[\"", $resp)[1])[0];
        $username = explode("/", explode("@", explode("\"", explode("\"url\":\"", $resp)[1])[0])[1])[0];

        $result = [
            'video'=>$video,
            'withoutWaterMark'=>$videoWithoutWaterMark,
            'user'=>$username,
            'thumb'=>$thumb,
            'error'=>false,
            'message'=>false
        ];
    }
    else
    {
        $result = [
            'video'=>false,
            'withoutWaterMark'=>false,
            'user'=>false,
            'thumb'=>false,
            'error'=>true,
            'message'=>"Please double check your url and try again."
        ];
    }

    return $result;

}


private function cUrl($url)
{
    $user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;

}

另一个获取没有水印的视频网址的功能是

private function WithoutWatermark($url)
{
    //videi id for example 6795008547961752326
    $dd = explode("video/",$url);
    $url = "https://api2.musical.ly/aweme/v1/playwm/?video_id=".$dd[1];
    return $url;
}

请帮助我找到 tiktok 视频 ID,或任何方式来创建无水印视频的下载链接。如何找到视频的视频 ID,所以我将使用此视频 ID 创建下载链接“ https://api2.musical.ly/aweme/v1/playwm/?video_id=v09044b90000bpfdj5q91d8vtcnie6o0 ”;

4

1 回答 1

1

您的无水印功能不起作用。

如果你有这样的网址:tiktok.com/@user/video/123456

然后你可以做一个卷曲:

$data = cUrl($url)

您将从 tiktok 获得一个页面,使用正则表达式您可以提取 url 视频:

https://v16.muscdn.com/123etc

然后再次使用上面的 url 卷曲,响应是字节,在内部使用正则表达式,您可以找到类似 vid:yourvideoid 的内容

于 2020-05-05T09:21:32.643 回答