YouTube API Decoded JSON Data in Loop?
-
Hello,
I am having a very difficult time echoing out JSON data within a loop. I have assigned a custom-field to each post which contains a YouTube video ID (key ytid).
Here’s what I currently have in the loop:
<?php $videoID = get_post_meta($post->ID, 'ytid', true); $query_url = 'http://gdata.youtube.com/feeds/api/videos/' . $videoID . '?v=2&alt=jsonc'; $json = json_decode($query_url); $views = $json->data->views; echo $views; ?>This echoes back nothing. I’d like to ideally be able to pull additional info from the JSON file as well, such as comment count, like count, etc. Is my syntax incorrect? Any help would be greatly appreciated!
The topic ‘YouTube API Decoded JSON Data in Loop?’ is closed to new replies.