summaryrefslogtreecommitdiff
path: root/youtube.php
diff options
context:
space:
mode:
authorHorus32014-02-24 16:42:14 +0100
committerHorus32014-02-24 16:42:14 +0100
commit06f945f27840b53e57795dadbc38e76f7e11ab1c (patch)
tree689d5c7f4ffa15460c7e90f47c6a7dd59ce4e8bd /youtube.php
downloadrandom-06f945f27840b53e57795dadbc38e76f7e11ab1c.tar.gz
init
Diffstat (limited to 'youtube.php')
-rw-r--r--youtube.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/youtube.php b/youtube.php
new file mode 100644
index 0000000..9b22256
--- /dev/null
+++ b/youtube.php
@@ -0,0 +1,44 @@
+<?php
+
+/*
+*This generates a Youtube-ID and checks if available. This is the most stupid way I can think of.
+*NO, THIS SHIT DOESN'T WORK!! You will get 404's everytime.
+*/
+
+$clientLibraryPath = "zend/library";
+$oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $clientLibraryPath);
+
+function get_video(){
+
+ $youtube_array = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q",
+ "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
+ "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "_", "-", "0", "1", "2", "3", "4",
+ "5", "6", "7", "8", "9" );
+
+ $length = count($youtube_array);
+
+ $string = "";
+
+ for ($i=0;$i<11;$i++){
+ $index = mt_rand(0,$length-1);
+ $string = "$string".$youtube_array[$index];
+ }
+
+ if ($data =file_get_contents("https://gdata.youtube.com/feeds/api/videos/".$string."")){
+
+ $xmldata = simplexml_load_string($data);
+
+ echo $xmldata->title[0];
+
+ return $string;
+ } else {
+ get_video();
+ }
+}
+
+$searchstring = get_video();
+
+echo $searchstring;
+
+
+// <iframe width="560" height="315" src="//www.youtube.com/embed/" frameborder="0" allowfullscreen></iframe>