在youtube API php中获取错误数量的结果

在youtube API php中获取错误数量的结果,php,youtube,Php,Youtube,我正在尝试使用以下代码从youtube获取视频: $youtube_api_url = "https://www.googleapis.com/youtube/v3/search?key=".$new_key->api_key; $youtube_api_url = $youtube_api_url."&order=relevance&type=video&maxResults=20&part=snippet&vide

我正在尝试使用以下代码从youtube获取视频:

        $youtube_api_url = "https://www.googleapis.com/youtube/v3/search?key=".$new_key->api_key;
        $youtube_api_url = $youtube_api_url."&order=relevance&type=video&maxResults=20&part=snippet&videoCategoryId=10&q=". urlencode(preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s', '',$trackRecord->name));
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_URL,$youtube_api_url);
        $result=curl_exec($ch);

        $response = json_decode($result, true);
        echo "<pre>"; print_r($response); die;

如您所见,它显示了总计和每页结果,如下所示:

[pageInfo]=>数组 ( [totalResults]=>14 [结果每页]=>20 )


如何获得所有结果?

您可能发布了错误的数据。我们无法看到[pageInfo]。正如您所看到的,它显示的是[pageInfo]=>Array([totalResults]=>14[resultsPerPage]=>20)的总结果和每页结果
Array
( 
    [items] => Array
        (
            [0] => Array
                (
                    [kind] => youtube#searchResult
                    [etag] => "m2yskBQFythfE4irbTIeOgYYfBU/ne5AZXpdoLtAn-mlwu4ipioOQ_I"
                    [id] => Array
                        (
                            [kind] => youtube#video
                            [videoId] => dB0ITzfbwfw
                        )

                    [snippet] => Array
                        (
                            [publishedAt] => 2017-01-23T17:31:23.000Z
                            [channelId] => UCdW5nPo1oyD2vLkvoYijmEg
                            [title] => Lihtz Kamraz "The Switch Up" Interview Part 2
                            [description] => In 2016, a lot of break out artists emerged and made a mark in the game. As 2017 begins, one name that you should definitely be on the lookout for is Lihtz ...
                            [thumbnails] => Array
                                (
                                    [default] => Array
                                        (
                                            [url] => https://i.ytimg.com/vi/dB0ITzfbwfw/default.jpg
                                            [width] => 120
                                            [height] => 90
                                        )

                                    [medium] => Array
                                        (
                                            [url] => https://i.ytimg.com/vi/dB0ITzfbwfw/mqdefault.jpg
                                            [width] => 320
                                            [height] => 180
                                        )

                                    [high] => Array
                                        (
                                            [url] => https://i.ytimg.com/vi/dB0ITzfbwfw/hqdefault.jpg
                                            [width] => 480
                                            [height] => 360
                                        )

                                )

                            [channelTitle] => HIPHOPSINCE1987TV
                            [liveBroadcastContent] => none
                        )

                )

        )

)