Skip to content

Instantly share code, notes, and snippets.

@gerrgg
Created August 7, 2020 13:02
Show Gist options
  • Save gerrgg/f04fb87c01082aaceb774a0e5e39ebe2 to your computer and use it in GitHub Desktop.
Save gerrgg/f04fb87c01082aaceb774a0e5e39ebe2 to your computer and use it in GitHub Desktop.
function getYoutubeVideoStatus( $video_id ){
/**
* Get the status of a youtube video
* @param string $video_id
* @return string | false
*/
$url = "https://www.googleapis.com/youtube/v3/videos?part=status&id=$video_id&key=YOUR_API_KEY_HERE";
$results = json_decode(file_get_contents($url));
return( isset( $results->items[0]->status->privacyStatus ) ) ? $results->items[0]->status->privacyStatus : false;
}
getYoutubeVideoStatus('imF5oTuALTo'); //false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment