https://productforums.google.com/forum/#!msg/youtube/Ze0mx-MVebA/BYK8KM20NgAJ
http://johnnythetank.github.io/youtube-channel-name-converter/
arrays, json refresher
https://www.taniarascia.com/how-to-use-json-data-with-php-or-javascript/
<?php
// - Needs API key
// - Channel Name
// RETURN CHANNEL ID FOR CHANNEL USER NAMES
$channel = "https://www.youtube.com/user/RussiaToday";
$channel2 = "https://www.youtube.com/channel/UCIzc1_X3OAFquArF3EOVeWw/" ;
$clean_url = preg_replace('{/$}', '', $channel2); // remove last forward slash from URL
$parts = explode('/', $clean_url) ;
/*
Array
(
[0] => https:
[1] =>
[2] => www.youtube.com
[3] => user
[4] => RussiaToday
)
*/
if (strpos($channel, 'user') ) {
$json = "https://www.googleapis.com/youtube/v3/channels?part=snippet&forUsername=". end($parts) . "&key=AIzaSyDHco0SKPqaIDKOT3-IEcednBMfOrMbLS8";
$jsonfile = file_get_contents($json);
$decoded = json_decode($jsonfile) ;
echo 'Decoded URL: ' . $decoded->items[0]->id;
}
else {
echo 'Default Channel ID, No Api Call: ' . end($parts) ;
}