php - How to get number of video views with YouTube API V3? -


i use code achieve don't work :

 <?php $json = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=statistics&id=hqepb5hzub0&key={your-api-key}"); $json_data = json_decode($json); $views = $json_data->{'entry'}->{'yt$statistics'}->{'viewcount'}; echo $views; ?> 

thanks

try this:

$json = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=statistics&id=hqepb5hzub0&key={your-api-key}"); $json_data = json_decode($json, true); echo $json_data['items'][0]['statistics']['viewcount']; 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -