-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideo.php
More file actions
96 lines (74 loc) · 4.24 KB
/
Copy pathvideo.php
File metadata and controls
96 lines (74 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
if(isset($_GET['id'])) {
$videoId = $_GET['id'];
$apikey = 'AIzaSyC_14WkUJnv_w1jrZtLV2o-xq0U4J8a6yA';
$googleApiUrl = 'https://www.googleapis.com/youtube/v3/videos?id=' . $videoId . '&key=' . $apikey . '&part=snippet';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $googleApiUrl);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response);
$value = json_decode(json_encode($data), true);
$title = $value['items'][0]['snippet']['title'];
$description = $value['items'][0]['snippet']['description'];
}
?>
<!DOCTYPE html>
<html >
<head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title><?php echo $title;?></title>
<meta property="fb:app_id" content="MY_APP_ID" />
<meta property="og:site_name" content="YouTube">
<meta property="og:url" content="https://www.youtube.com/watch?v=<?php echo $videoId;?>">
<meta property="og:title" content="<?php echo $title;?>"">
<meta property="og:image" content="https://i.ytimg.com/vi/<?php echo $videoId;?>/hqdefault.jpg">
<meta property="og:description" content="<?php echo $description;?>">
<meta property="al:ios:app_store_id" content="544007664">
<meta property="al:ios:app_name" content="YouTube">
<meta property="al:ios:url" content="vnd.youtube://www.youtube.com/watch?v=<?php echo $videoId;?>&feature=applinks">
<meta property="al:android:url" content="vnd.youtube://www.youtube.com/watch?v=<?php echo $videoId;?>&feature=applinks">
<meta property="al:android:app_name" content="YouTube">
<meta property="al:android:package" content="com.google.android.youtube">
<meta property="al:web:url" content="https://www.youtube.com/watch?v=<?php echo $videoId;?>&feature=applinks">
<meta property="og:type" content="video">
<meta property="og:video:url" content="https://www.youtube.com/embed/<?php echo $videoId;?>">
<meta property="og:video:secure_url" content="https://www.youtube.com/embed/<?php echo $videoId;?>">
<meta property="og:video:type" content="text/html">
<meta property="og:video:width" content="1280">
<meta property="og:video:height" content="720">
<meta property="og:video:url" content="http://www.youtube.com/v/<?php echo $videoId;?>?version=3&autohide=1">
<meta property="og:video:secure_url" content="https://www.youtube.com/v/<?php echo $videoId;?>?version=3&autohide=1">
<meta property="og:video:type" content="application/x-shockwave-flash">
<meta property="og:video:width" content="1280">
<meta property="og:video:height" content="720">
</head>
<body>
<div class="video-container">
<p><iframe width="auto" height="auto" src="https://www.youtube.com/embed/<?php echo $videoId;?>?feature=oembed" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></p>
</div>
<script type="text/javascript">
window.onload = function() {
var desktopFallback = "https://youtube.com/watch?v=<?php echo $videoId;?>",
mobileFallback = "https://youtube.com/watch?v=<?php echo $videoId;?>",
app = "vnd.youtube://<?php echo $videoId;?>";
if( /Android|iPhone|iPad|iPod/i.test(navigator.userAgent) ) {
window.location = app;
window.setTimeout(function() {
window.location = mobileFallback;
}, 25);
} else {
window.location = desktopFallback;
}
function killPopup() {
window.removeEventListener('pagehide', killPopup);
}
window.addEventListener('pagehide', killPopup);
};
</script>
</body>
</html>