- <?php
- $url = $_GET['url'];
- $json = jiexi(curl_302($url));
- echo json_encode($json);
- function jiexi($HtmlCode)
- {
- preg_match_all('/(?:\/video\/)(.*)(?:\/\?)/i', $HtmlCode, $itemId);
- $mp4_url = "https://www.iesdouyin.com/web/api/v2/aweme/iteminfo/?item_ids=" . $itemId[1][0];
- $json = json_decode(file_get_contents($mp4_url));
- $json = $json->item_list[0];
- $author = $json->author;
- $author_name = $author->nickname;
- $author_sign = $author->signature;
- $video = $json->video;
- $video_name = $json->desc;
- $video_cover = $video->origin_cover->url_list[0];
- $video_url = $video->play_addr->url_list[0];
- $video_url = curl_302(str_ireplace('playwm', 'play', $video_url));
- $video_comment = $json->statistics->comment_count;
- $video_like = $json->statistics->digg_count;
- $music = $json->music;
- $music_title = $music->title;
- $music_url = $music->play_url->uri;
- if (empty($name) & empty($video_url)) {
- return ['code' => 100, 'msg' => '系统错误,解析失败'];
- } else {
- $json = array(
- 'author_name' => $author_name,
- 'author_sign' => $author_sign,
- 'video_name' => $video_name,
- 'video_like' => $video_like,
- 'video_comment' => $video_comment,
- 'video_cover' => $video_cover,
- 'video_url' => $video_url,
- 'music_title' => $music_title,
- 'music_url' => $music_url,
- );
- $json = array(
- 'code' => 200,
- 'msg' => 'ok',
- 'data' => $json
- );
- return $json;
- }
- }
- function curl_302($url)
- {
- $url_302_json = json_decode(file_get_contents('http://res.abeim.cn/api-dwz_longurl?url=' . $url), true);
- if ($url_302_json['code'] == 200) {
- return $url_302_json['long_url'];
- } else {
- die(json_encode(["code" => 101, 'url' => $url, "msg" => "系统异常,网址还原失败,检查链接是否正确"]));
- }
- }
复制代码 源码下载:
|
|