检索多个YouTube用户的最新视频并按最新视频排序


Retrive recent videos of multiple YouTube users and order by most recent

所以正如标题所暗示的那样,我希望使用PHP从多个YouTube频道检索最近的视频及其JSON数据。我已经环顾了stackoverflow,但我找不到我正在寻找的用户的回复(即使进行了调整。

我能够使用此代码从单个用户那里获取最近上传的 youtube 视频。

<?php
$xml = simplexml_load_file("https://gdata.youtube.com/feeds/api/users/1jBoA_hgXTtGgs8OIrfYkg/upload     s");
$json = json_encode($xml);
$videos = json_decode($json, true);
var_dump($videos);

注意:我显示的代码确实有效,但我正在寻找代码来按顺序显示来自多个用户的视频。

提前致谢:)

如果你知道用户的名字,我说你这样做,你可以简单地将它们放在一个数组中,然后使用你在每次迭代中工作的代码遍历数组。

// Array of users (dummy values....)
$users = array("1jBoA_hgXTtGgs8OIrfYkg", "4dfg_hgXTtGgs8OIrfYkg", "6dzgdf_hgXTtGgs8OIrfYkg");
$allVideoLists = array();
// Iterate over each user in the 'users' array one by one
foreach ($users as $thisUser) {
         //Get the video list for this user and create an object from the JSON
         $xml=simplexml_load_file("https://gdata.youtube.com/feeds/api/users/" + $thisUser + "/uploads");
         $json = json_encode($xml);
         $videos = json_decode($json, true);
         //Add this users Video list to the array of all user's video lists
         $allVideoLists[] = $videos
}