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?
June 13, 2013 at 4:53 am
#138527
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?