Php 多个YouTube v2 API调用未检索所有内容

Php 多个YouTube v2 API调用未检索所有内容,php,json,youtube-api,gdata-api,youtube-data-api,Php,Json,Youtube Api,Gdata Api,Youtube Data Api,好的,我正在PHP服务器上使用YouTube v2 gdata API 我的尝试是抽取订阅量最大的前100名用户(有效),然后为每个用户抽取前50名视频,并将它们整齐地以JSON格式放入各个.txt文件中,以便我可以根据需要访问它们。以下是我所拥有的: <?PHP $data = json_decode(file_get_contents("http://<EXAMPLE>.com/appData/?load=100&alt=json"),true); foreac

好的,我正在PHP服务器上使用YouTube v2 gdata API

我的尝试是抽取订阅量最大的前100名用户(有效),然后为每个用户抽取前50名视频,并将它们整齐地以JSON格式放入各个.txt文件中,以便我可以根据需要访问它们。以下是我所拥有的:

<?PHP

$data = json_decode(file_get_contents("http://<EXAMPLE>.com/appData/?load=100&alt=json"),true);

foreach($data['entry'] as $entry){
    $ytUser = $entry['YouTuberName'];
    $ytURL = $entry['TransitionURL'];
    $ytUserString = str_replace(' ', '', $ytUser);

    $json_array = array();  

    $json = json_decode(file_get_contents($ytURL . "/uploads?v=2&alt=jsonc&max-results=50&orderby=viewCount"),true);

    for($i=0;$i!=count($json['data']['items']);$i++){
        $item = $json['data']['items'][$i];
            $itemID = $item['id'];
            $numRatings = $item['ratingCount'];
            $tmp_json = json_decode(file_get_contents("https://gdata.youtube.com/feeds/api/videos/".$itemID."?v=2&alt=json"),true);
            $tmp_arr['id'] = $item['id'];
            $tmp_arr['uploaded'] = $item['uploaded'];
            $tmp_arr['title'] = $item['title'];
            $tmp_arr['thumbnail'] = $item['thumbnail']['hqDefault'];
            $tmp_arr['mplayer'] = $item['player']['mobile'];
            $tmp_arr['dplayer'] = $item['player']['default'];
            $tmp_arr['duration'] = $item['duration'];
            $tmp_arr['likes'] = $item['likeCount'];
            $tmp_arr['dislikes'] = (string)($numRatings - (int)$tmp_arr['likes']);
            $tmp_arr['views'] = $item['viewCount'];
            $tmp_arr['comments'] = $item['commentCount'];
            $tmp_arr['desc'] = $tmp_json['entry']['media$group']['media$description']['$t'];

            array_push($json_array,$tmp_arr);           
    }

    $json_arr = json_encode($json_array);
    $contents = "{\"entry\":" . $json_arr . "}";
    $filename = "/home/<USERNAME>/public_html/appData/popular/" . $ytUserString . ".txt";
    file_put_contents((string)$filename, $contents);
}
?>

代码非常简单,可以正常工作,但是在列表中的第三个用户之后,就不会再提取数据了。所以我有63.txt文件,但其中只有3个有JSON数据,其他60个只有空数组

我设置为$data的第一个链接是我从收集最多订阅YouTube的第一个API调用中设置的JSON