Reputation: 119
I have a question about the Youtube Api , i'm using the CodeIgniter YouTube API Library by jimdoescode https://github.com/jimdoescode/CodeIgniter-YouTube-API-Library. Imagine that you have 2 channels , channel x and y . I need to run a php code which shows me the most viewed videos per week from this tow channels ONLY in (ASC or DESC) order .
** the channels is not yours - it belongs to any user
Ex :
channel x has:
channel y has:
the php code should result the following
I’ve searched on the Youtube api , Developer's Guide, can you help me with some hints please?
Upvotes: 0
Views: 561
Reputation: 200
I don't believe you can pull feeds from two channels at once from the youtube API.
You would have to pull two feeds and merge the data in PHP and then sort.
As you say you are using the CI Youtube API Library, you would need to add the parameter orderby with a value of viewCount to the function you are using to pull the feed.
For example, if you are using getUserUploads() you would want something like:
$resultX = $this->youtube->getUserUploads('channelX',array('orderby'=>'viewCount'));
$resultY = $this->youtube->getUserUploads('channelY',array('orderby'=>'viewCount'));
How you parse the XML response results and convert them to an array for sorting I will leave up to you.
Upvotes: 1
Reputation: 1
http://gdata.youtube.com/feeds/api/users/USERNAME/uploads?orderby=viewCount&max-results=5
Replace USERNAME with the username of the user you want to check for.
Replace 5 with the videos you want to be sorted (shown).
Upvotes: 0