I have the below code for retrieving views and subscribers from a YouTube channel "?q=dsagov"
$UserID = $_GET['q'];
$data = file_get_contents('http://gdata.youtube.com/feeds/api/users/'. $UserID.'');
$xml = new SimpleXMLElement($data);
$stats_data = (array)$xml->children('yt', true)->statistics->attributes();
$stats_data = $stats_data['@attributes'];
echo 'Views = '.$stats_data['subscriberCount'].'<br />';
echo 'Subscribers = '.$stats_data['totalUploadViews'].'<br />';
I would like to take this one step further and find the YouTube channel ID based on a website address, in this case https://www.gov.uk/government/organisations/driving-standards-agency .
So either REGEX the website find the Channel ID or another method which I am not aware of using YouTube API, I can put the URL of the website and have it find the official channel is this possible?
Thanks in advance.
Just to clarify For example I would like to enter a URL in query "/?q=gov.uk/government/organisations/driving-standards-agency" what the script would do is find the YouTube Channel ID on the URL and run the API and display the results