Skip to content

Instantly share code, notes, and snippets.

@malkafly
Forked from webarthur/get_youtube_channel_ID.php
Created September 7, 2016 17:13
Show Gist options
  • Save malkafly/27aac07501283c153a275f2be5013cc7 to your computer and use it in GitHub Desktop.
Save malkafly/27aac07501283c153a275f2be5013cc7 to your computer and use it in GitHub Desktop.
Get youtube Channel ID by channel url
<?php
function get_youtube_channel_ID($url){
$html = file_get_contents($url);
preg_match("'<meta itemprop=\"channelId\" content=\"(.*?)\"'si", $html, $match);
if($match && $match[1]);
return $match[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment