How to Get all video from youtube channel

Posted by engineerisaac


Posted on 4 months ago

Here is a simple and easy way to get all the channels from a youtube account.



Your first step will be to acquire a youtube API key. Found https://console.cloud.google.com/apis/credentials At this link.



You then can use this PHP code








//https://console.cloud.google.com/apis/credentials



$grab_username = 'Insert_Username-HERE';

$google_key ='Insert-Key-HERE';



// Get the string from the URL

$json = file_get_contents('https://www.googleapis.com/youtube/v3/channels?key='. $google_key .'&forUsername='. $grab_username .'&part=id');



// Decode the JSON string into an object

$obj = json_decode($json);



// In the case of this input, do key and array lookups to get the values

echo $obj->items[0]->id;



$grab_id = $obj->items[0]->id;





$videoList = json_decode(file_get_contents('https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId='. $grab_id .'&maxResults=20&key='. $google_key .''));





foreach($videoList->items as $item){

//Embed video

if(isset($item->id->videoId)){

echo '

id->videoId.'" frameborder="0" allowfullscreen>

'. $item->snippet->title .'

';

}

}











Comments are For the Community.

If you would like to Comment, Consider joining the Community!

We believe in accountability. Your comments are connected to your profile.

Register Login


Other Engineerisaac Articles