Get YouTube video information using api in php
Follow below steps to get YouTube video information
Step 1:
Example:
https://www.youtube.com/watch?v=ZdP0KM49IVk
in this url video id is showing in Red color
Step 4: Add below code to your php file
<?php
$vdata = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id=VIDEO_ID&key=YOUR_APIKEY&part=snippet,contentDetails,statistics,status");
$result_data = json_decode($vdata, true);
echo "<pre>";
print_r($result_data);
?>
Step 1:
- create API key to authenticate with YouTube
- Login to google developer account https://console.developers.google.com
- Create / Select project
- Create new key or Get API key
Example:
https://www.youtube.com/watch?v=ZdP0KM49IVk
in this url video id is showing in Red color
Step 4: Add below code to your php file
<?php
$vdata = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id=VIDEO_ID&key=YOUR_APIKEY&part=snippet,contentDetails,statistics,status");
$result_data = json_decode($vdata, true);
echo "<pre>";
print_r($result_data);
?>
Comments
Post a Comment