1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[ GET ] PHP Scripts to check View Count of single youtube Video

Discussion in 'YouTube' started by kmzlink, Jun 26, 2012.

  1. kmzlink

    kmzlink Junior Member

    Joined:
    Feb 11, 2009
    Messages:
    125
    Likes Received:
    15
    Occupation:
    SEO WEBMASTER
    Location:
    Google Malaysia
    hi,

    This my first php scripts . This scripts is create to check single youtube video view count

    Tutorial

    1. First save this code as index.php
    Code:
    <html>
    <body>
    <center>
    <br />
    <br />
    <b>Put youtube Video ID Below:</b>
    <p></p>
    <form action="yt.php" method="post">
    <input type="text" name="fname" />
    <input type="submit" />
    </form>
    <b><p>Click Submit</p></b>
    </center>
    </body>
    </html>
    
    2. Second save this scripts as yt.php

    Code:
    <html>
    <body>
    <center>
    <br />
    <br />
    <br />
    <br />
    <b>
    <font size="20" color="green">
    <?php
    $video_ID = $_POST["fname"];
    $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;
    ?>
    
    </font>
    </b>
    </center>
    </body>
    </html>
    
    3. Create directory in your server/hosting then upload that scripts to your directory that you create

    p/s: by sharing this scripts maybe it can help certain people that want to check youtube single video view count. fro their project. Enjoy
     
    • Thanks Thanks x 2
  2. MicGrez

    MicGrez Regular Member

    Joined:
    Aug 11, 2011
    Messages:
    333
    Likes Received:
    103
    ahahha how great, now I dont need to look up my notepad notes for my urls then check every single one, can just have the stats on my site and track'em there, thanks man!
     
  3. centrum1337

    centrum1337 Junior Member

    Joined:
    Oct 19, 2012
    Messages:
    112
    Likes Received:
    9
    this code is not working anymore can you please update with entering multiple ID or URL's? thanks.
     
  4. kmzlink

    kmzlink Junior Member

    Joined:
    Feb 11, 2009
    Messages:
    125
    Likes Received:
    15
    Occupation:
    SEO WEBMASTER
    Location:
    Google Malaysia
    huh,

    i am not good with php scripts, and are you sure that scripts not working?

    hmm ok , are you looking something like this. It is easy man ;)

    http://www.youtube.com/watch?v=tLrdH1QcANU