Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End View Count from PHP function works, but sometimes it appears blank, How can I fix this? Re: View Count from PHP function works, but sometimes it appears blank, How can I fix this?

#138527
asiek
Participant

I used this PHP Function//


$video_ID = get_post_meta($post->ID, 'v_id', true);
$JSON = file_get_contents("https://gdata.youtube.com/feeds/api/videos/{$video_ID}?v=2&alt=json");
$JSON_Data = json_decode($JSON);
$views = $JSON_Data->{'entry'}->{'yt$statistics'}->{'viewCount'};
echo $views; ?>

Could it have something to do with Youtube rather than the function I used or what? Any ideas/solutions?