Share function PHP Get link Google Drive chuẩn
Drive Google là một server lớn nơi chúng ta có thể lưu trữ và chia sẻ file hoàn toàn miễn phí, hôm nay mình sẽ share code get link drive cho bạn nào làm site phim mà muốn chạy link drive nhé.
Viết vậy cho newbie nhìn cũng dễ hiểu, có thể áp dụng cho get link các site khác cũng tương tự vậy
Demo: http://www.anime9x.com/aniplugins
Bạn nào có VPS hỗ trợ IPv6 thì xài code này nhé
Chúc các bạn thành công và tận dụng được tối đa những gì mà Google cho bạn!
Nguồn: T-Design - Diễn đàn DaiVietPDA.Vn
Viết vậy cho newbie nhìn cũng dễ hiểu, có thể áp dụng cho get link các site khác cũng tương tự vậy
Demo: http://www.anime9x.com/aniplugins
<?php
function ViewSource($url){
$ch = curl_init();
$timeout = 15;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.69 Safari/537.36");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function GoogleDrive($curl){
$get = ViewSource(' http://www.anime9x.com/apidrive.php?url='.$curl);
$remove = str_replace('\/','/',$get);
preg_match_all('#"(. ?)":"(. ?)"#',$remove,$data);
foreach ($data[2] as $i => $quality) {
if (strpos($data[1][$i], '1080') !== false) {
$AnimeVN .= '<source src="'.$data[2][$i].'" type="video/mp4" data-res="1080" />';
} elseif (strpos($data[1][$i], '720') !== false) {
$AnimeVN .= '<source src="'.$data[2][$i].'" type="video/mp4" data-res="720" />';
} elseif (strpos($data[1][$i], '480') !== false) {
$AnimeVN .= '<source src="'.$data[2][$i].'" type="video/mp4" data-res="480" />';
} elseif (strpos($data[1][$i], '360') !== false) {
$AnimeVN .= '<source src="'.$data[2][$i].'" type="video/mp4" data-res="360" />';
}
}
return $AnimeVN;
}
?>
function ViewSource($url){
$ch = curl_init();
$timeout = 15;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.69 Safari/537.36");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function GoogleDrive($curl){
$get = ViewSource(' http://www.anime9x.com/apidrive.php?url='.$curl);
$remove = str_replace('\/','/',$get);
preg_match_all('#"(. ?)":"(. ?)"#',$remove,$data);
foreach ($data[2] as $i => $quality) {
if (strpos($data[1][$i], '1080') !== false) {
$AnimeVN .= '<source src="'.$data[2][$i].'" type="video/mp4" data-res="1080" />';
} elseif (strpos($data[1][$i], '720') !== false) {
$AnimeVN .= '<source src="'.$data[2][$i].'" type="video/mp4" data-res="720" />';
} elseif (strpos($data[1][$i], '480') !== false) {
$AnimeVN .= '<source src="'.$data[2][$i].'" type="video/mp4" data-res="480" />';
} elseif (strpos($data[1][$i], '360') !== false) {
$AnimeVN .= '<source src="'.$data[2][$i].'" type="video/mp4" data-res="360" />';
}
}
return $AnimeVN;
}
?>
Bạn nào có VPS hỗ trợ IPv6 thì xài code này nhé
<?php
function GoogleDrive($curl){
$get = AniSource($curl);
$cat = explode(',["fmt_stream_map","', $get);
$cat = explode('"]', $cat[1]);
$cat = explode(',', $cat[0]);
foreach($cat as $link){
$cat = explode('|', $link);
$links = str_replace(array('\u003d', '\u0026'), array('=', '&'), $cat[1]);
if($cat[0] == 37) {$f1080p = $links;}
if($cat[0] == 22) {$f720p = $links;}
if($cat[0] == 35) {$f480p = $links;}
if($cat[0] == 43) {$f360p = $links;}
}
if(isset($f1080p)){
$AnimeVN = "<source src=\"".$f1080p."\" type=\"video/mp4\" data-res=\"1080\" />\n<source src=\"".$f720p."\" type=\"video/mp4\" data-res=\"720\" />\n<source src=\"".$f480p."\" type=\"video/mp4\" data-res=\"480\" />\n<source src=\"".$f360p."\" type=\"video/mp4\" data-res=\"360\" />";
} elseif(isset($f720p)){
$AnimeVN = "<source src=\"".$f720p."\" type=\"video/mp4\" data-res=\"720\" />\n<source src=\"".$f480p."\" type=\"video/mp4\" data-res=\"480\" />\n<source src=\"".$f360p."\" type=\"video/mp4\" data-res=\"360\" />";
} elseif(isset($f480p)){
$AnimeVN = "<source src=\"".$f480p."\" type=\"video/mp4\" data-res=\"480\" />\n<source src=\"".$f360p."\" type=\"video/mp4\" data-res=\"360\" />";
} elseif(isset($f360p)){
$AnimeVN = "<source src=\"".$f360p."\" type=\"video/mp4\" data-res=\"360\" />";
} else {
$AnimeVN = '<source src="https://lh3.googleusercontent.com/XpE2g3UEIu7WblZ1P-Elc7KFutP13AbO1algeZgqXV0=m37" type="video/mp4" data-res="360" />';
}
return $AnimeVN;
}
?>
function GoogleDrive($curl){
$get = AniSource($curl);
$cat = explode(',["fmt_stream_map","', $get);
$cat = explode('"]', $cat[1]);
$cat = explode(',', $cat[0]);
foreach($cat as $link){
$cat = explode('|', $link);
$links = str_replace(array('\u003d', '\u0026'), array('=', '&'), $cat[1]);
if($cat[0] == 37) {$f1080p = $links;}
if($cat[0] == 22) {$f720p = $links;}
if($cat[0] == 35) {$f480p = $links;}
if($cat[0] == 43) {$f360p = $links;}
}
if(isset($f1080p)){
$AnimeVN = "<source src=\"".$f1080p."\" type=\"video/mp4\" data-res=\"1080\" />\n<source src=\"".$f720p."\" type=\"video/mp4\" data-res=\"720\" />\n<source src=\"".$f480p."\" type=\"video/mp4\" data-res=\"480\" />\n<source src=\"".$f360p."\" type=\"video/mp4\" data-res=\"360\" />";
} elseif(isset($f720p)){
$AnimeVN = "<source src=\"".$f720p."\" type=\"video/mp4\" data-res=\"720\" />\n<source src=\"".$f480p."\" type=\"video/mp4\" data-res=\"480\" />\n<source src=\"".$f360p."\" type=\"video/mp4\" data-res=\"360\" />";
} elseif(isset($f480p)){
$AnimeVN = "<source src=\"".$f480p."\" type=\"video/mp4\" data-res=\"480\" />\n<source src=\"".$f360p."\" type=\"video/mp4\" data-res=\"360\" />";
} elseif(isset($f360p)){
$AnimeVN = "<source src=\"".$f360p."\" type=\"video/mp4\" data-res=\"360\" />";
} else {
$AnimeVN = '<source src="https://lh3.googleusercontent.com/XpE2g3UEIu7WblZ1P-Elc7KFutP13AbO1algeZgqXV0=m37" type="video/mp4" data-res="360" />';
}
return $AnimeVN;
}
?>
Chúc các bạn thành công và tận dụng được tối đa những gì mà Google cho bạn!
Nguồn: T-Design - Diễn đàn DaiVietPDA.Vn