开发者

Is it possible to reverse the orderby results with youtube API?

开发者 https://www.devze.com 2023-03-16 19:02 出处:网络
re: http://code.goog开发者_高级运维le.com/apis/youtube/2.0/developers_guide_php.html#Searching_for_Videos

re: http://code.goog开发者_高级运维le.com/apis/youtube/2.0/developers_guide_php.html#Searching_for_Videos

Im using the orderby or as the Zend gdata API calles it setOrderBy to get results ranked by viewcount. they are returned in Descending order and I need Ascending. Possible?


I know i'm kinda late, but I'm having the same issue. My approach (if I find out that the API is not offering this) is to simply request the last part by using 'start-index'. it's a little bit annoying, but possible.

$feedURL = 'http://gdata.youtube.com/feeds/api/videos?q='. $query .'author=' . $author;
$sxml = simplexml_load_file($feedURL);
$ind = $sxml->children('http://a9.com/-/spec/opensearchrss/1.0/')->totalResults;
$feedURL = 'http://gdata.youtube.com/feeds/api/videos?q='. $query .
             'author='. $author .'orderby=published'.
             '&max-result=100&start-index=' . ($ind-100);
/* save to some array and use. */
  • If you found an easier way - I'll be happy to know.


If you can get the results into an array, you can then reverse the order by calling array_reverse().

0

精彩评论

暂无评论...
验证码 换一张
取 消