D
D
dojdimon2014-07-06 00:17:25
YouTube
dojdimon, 2014-07-06 00:17:25

How to get Youtube playlist view counter value?

Taking the value of the video counter is simple:

<?php
    $youtube_view_count = json_decode(file_get_contents('http://gdata.youtube.com/feeds/api/videos/snHJl1kSz6A?v=2&alt=json'))->entry->{'yt$statistics'}->viewCount;
    echo $youtube_view_count;
?>

But how to take the value of the views of the entire playlist is not clear.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladlen Grachev, 2014-07-06
@dojdimon

Take all the info on the playlist ( https://gdata.youtube.com/feeds/api/playlists/8BCD... ), and sum up the viewCount. XML, I think, is better to parse with some SimpleXML , and loop over the resulting object. Well, either pull out everything with regexps, but make sure that something from the descriptions / names does not get into the selection then.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question