Skip to content

Instantly share code, notes, and snippets.

@6ui11em
Created May 13, 2021 00:12
Show Gist options
  • Save 6ui11em/da6ca573670b9e80d3e64a0764804200 to your computer and use it in GitHub Desktop.
Save 6ui11em/da6ca573670b9e80d3e64a0764804200 to your computer and use it in GitHub Desktop.
Youtube: Get Video Information API call PHP #youtube #php #api #video
$api_key = "API Key"
$video_id = "Video ID"
$url = "https://www.googleapis.com/youtube/v3/videos?id=" . $video_id . "&key=" . $api_key . "&part=snippet,contentDetails,statistics,status";
$json = file_get_contents($url);
$getData = json_decode( $json , true);
foreach((array)$getData['items'] as $key => $gDat){
$title = $gDat['snippet']['title'];
}
// Output title
echo $title;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment