From f299ec8fcf3bbc06b8bbedc812f13a3e55c35c87 Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Fri, 15 Sep 2017 20:10:22 -0400 Subject: [PATCH] Update index.php --- community/index.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/community/index.php b/community/index.php index 604f710..47930ef 100644 --- a/community/index.php +++ b/community/index.php @@ -114,6 +114,32 @@ if ($i < 1000) { // parse only 10 items $i++; } +$channel_id = 'UCrHT3Lt0Mg90bspbMHJfTcA'; // put the channel id here +$youtube = file_get_contents('https://www.youtube.com/feeds/videos.xml?channel_id='.$channel_id); +$xml = simplexml_load_string($youtube, "SimpleXMLElement", LIBXML_NOCDATA); +$json = json_encode($xml); +$youtube = json_decode($json, true); +$yt_vids = array(); +$count = 0; +foreach ($youtube['entry'] as $k => $v) { + $yt_vids[$count]['id'] = str_replace('http://www.youtube.com/watch?v=', '', $v['link']['@attributes']['href']); + $yt_vids[$count]['title'] = $v['title']; + $count++; +} +print_r($yt_vids); +$channel_id = 'UCxzARKt0_U0sLHbF4pDN1Pw'; // put the channel id here +$youtube = file_get_contents('https://www.youtube.com/feeds/videos.xml?channel_id='.$channel_id); +$xml = simplexml_load_string($youtube, "SimpleXMLElement", LIBXML_NOCDATA); +$json = json_encode($xml); +$youtube = json_decode($json, true); +$yt_vids = array(); +$count = 0; +foreach ($youtube['entry'] as $k => $v) { + $yt_vids[$count]['id'] = str_replace('http://www.youtube.com/watch?v=', '', $v['link']['@attributes']['href']); + $yt_vids[$count]['title'] = $v['title']; + $count++; +} +print_r($yt_vids); ?>