Getting a YouTube videos tags using the YouTube api in PHP is quiet easy, just follow this guide. You will need your YouTube api key!
It easy to just make a function, this also helps with repeat use!
functions.php
function video_tag($tag, $video_id)
{
$api_key = 'YOU API KEY HERE';
$data = json_decode(file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=snippet&id=" . $video_id . "&key=".$api_key.""), true);
$tag = $data['items'][0]['snippet']['tags'][$tag];
return $tag;
} Here we have a function that will return the tag depending on your tag key. 0 is the first tag… 1 is the next and so forth.
An example for this function being used on this Casey Neistat video
include('functions.php');
echo video_tag(1,'0-7wMD5ISIs');//abandoned mall
echo video_tag(3,'0-7wMD5ISIs');//samsung His second tag for the video was “abandoned mall and his fourth tag was “samsung”.
You can see the result of the whole api call the function does in this spoiler:
And that’s how to easily get a YouTube videos tags using the YouTube api in PHP.
A drained and empty Kennington reservoir images from a drone in early July 2024. The…
Merrimu Reservoir from drone. Click images to view larger.
Using FTP and PHP to get an array of file details such as size and…
Creating and using Laravel form requests to create cleaner code, separation and reusability for your…
Improving the default Laravel login and register views in such a simple manner but making…
Laravel validation for checking if a field value exists in the database. The validation rule…