Grow your CSS skills. Land your dream job.

View Count from PHP function works, but sometimes it appears blank, How can I fix this?

  • # June 13, 2013 at 4:50 am

    Every once in awhile I visit my blog page and the View Count for videos are blank…
    I then refresh the page multiple times and all of the sudden View Count will appear again.
    I don’t understand what is happening…

    # June 13, 2013 at 4:50 am

    @AlenAbdula No the issue wasn’t resolved :/

    # June 13, 2013 at 4:53 am

    I used this PHP Function//

    < ?php
    $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?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".