Hướng dẫn get link video trang tv.zing.vn


Nhanh chóng, ngắn gọn, dễ dàng nhất đó là sử dụng API để getlink TvZing.

Cấu trúc link API:

http://api.tv.zing.vn/2.0/media/info?api_key=Key đã đăng ký&media_id=ID-Video


Api cung cấp những gì?

{
 "response": {
 "id": 151131,
 "require_premium": false,
 "title": "",
 "full_name": "Sakurako-san no Ashimoto ni wa Shitai ga Umatteiru - Tập 1",
 "episode": 1,
 "release_date": "20/10/2015",
 "duration": 1417,
 "thumbnail": "2015/1020/12/ede2edb5f87667b1293b3a3eef57a086_1.jpg",
 "file_url": "stream12.tv.zdn.vn/streaming/30d81b6df7ffc876fcd62cd0ae2c6739/56583455/2015/1020/12/f0e5e8a96291d1fb7e47ccacf506c11f.mp4?format\u003df360\u0026device\u003dother",
 "other_url": {
 "Video720": "stream12.tv.zdn.vn/streaming/4ce9d5b0880733c72cd138d7009b2a6f/56583455/Video720/2015/1020/12/7c19cc59c8ffc75d9e1aa97191c8a4d9.mp4?format\u003df720\u0026device\u003dother",
 "Video480": "stream12.tv.zdn.vn/streaming/f171d498f13f47a8b8178ac89145ba36/56583455/Video480/2015/1020/12/38717167bdf43a70ad806d557e4655a5.mp4?format\u003df480\u0026device\u003dother",
 "Video3GP": "stream.m.tv.zdn.vn/tv/6a7085e1cc898d16ae66d26596ee1fef/56583455/Video3GP/2015/1020/12/54a11262442475bf40b788276309d3f6.3gp?format\u003df3gp\u0026device\u003dother"
 },
 "download_url": { "Video3GP": "dl.stream.m.tv.zdn.vn/tv/6a7085e1cc898d16ae66d26596ee1fef/56583455/Video3GP/2015/1020/12/54a11262442475bf40b788276309d3f6.3gp?format\u003df3gp\u0026device\u003dother"
 },
 "hls": {},
 "link_url": "http://tv.zing.vn/video/sakurako-san-no-ashimoto-ni-wa-shitai-ga-umatteiru-tap-1/IWZB9EDB.html",
 "program_id": 3788,
 "program_name": "Sakurako-san no Ashimoto ni wa Shitai ga Umatteiru",
 "program_thumbnail": "channel/9/1/9122f8400f0703cfd238de04438eca4e_1445267077.jpg",
 "program_genre": [ {
 "id": 83,
 "name": "Hoạt Hình" }
 ],
 "listen": 22332,
 "comment": 2,
 "like": 380,
 "rating": 9.542662116040956,
 "next_media_id": 151132,
 "sub_title": {},
 "tracking": {}
 }
 }

Đó là những gì có thể lấy được qua API



Cuối cùng là Code Getlink TvZing [API]:

<?php
 if(isset($_GET['link']) && $_GET['link']!=null){
 $link = $_GET['link'];//Link cần lấy
 preg_match('/http:\/\/tv.zing.vn\/(.*)\/(.*)\/(.*).html/U', $link, $id);//Lấy ID phim - video
 $api = 'http://api.tv.zing.vn/2.0/media/info?api_key=d04210a70026ad9323076716781c223f&media_id='.$id[3];//Link API
 $view_source = file_get_contents($api);//View-source
 $data = json_decode($view_source, true);//Json Decode
 echo '720p: http://'.$data['response']['other_url']['Video720'].'<br>';
 echo '480p: http://'.$data['response']['other_url']['Video480'].'<br>';
 echo '360p mp4: http://'.$data['response']['file_url'].'<br>';
 echo '360p 3GP: http://'.$data['response']['other_url']['Video3GP'];
 }
?>
Share on Google Plus

About NHOCLAK DJ

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

0 nhận xét:

Đăng nhận xét