Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Youtube api Youtube数据API v3-配额使用问题_Youtube Api_Quota_Youtube Data Api - Fatal编程技术网

Youtube api Youtube数据API v3-配额使用问题

Youtube api Youtube数据API v3-配额使用问题,youtube-api,quota,youtube-data-api,Youtube Api,Quota,Youtube Data Api,在我的应用程序中,我希望使用基于用户的配额(请求/秒/用户)。我正在发送随机(用于测试查询)quotaUser和我的所有请求。但是,在控制台中,我看到配额()的总体使用有所增加。quotaUser参数的传输不会影响任何内容。也许我没有正确理解有关配额使用的文件。是否可以每天从多个应用程序用户执行超过1000000个请求 这是我的密码: $client = new Google_Client(); $client->setAuthConfigFile(SITE_PATH .

在我的应用程序中,我希望使用基于用户的配额(请求/秒/用户)。我正在发送随机(用于测试查询)quotaUser和我的所有请求。但是,在控制台中,我看到配额()的总体使用有所增加。quotaUser参数的传输不会影响任何内容。也许我没有正确理解有关配额使用的文件。是否可以每天从多个应用程序用户执行超过1000000个请求

这是我的密码:

    $client = new Google_Client();
    $client->setAuthConfigFile(SITE_PATH . '/vendor/access_data.json');
    $client->setScopes('https://www.googleapis.com/auth/youtube');
    $client->setAccessType('offline');
    $client->setApprovalPrompt('force');
    $redirect = filter_var('http://' . $_SERVER['HTTP_HOST'] . '/test', FILTER_SANITIZE_URL);
    $client->setRedirectUri($redirect);
    $youtube = new Google_Service_YouTube($client);

    if (isset($_GET['code']))
    {
        $userId = rand(1000, 100000);
        $client->authenticate($_GET['code']);
        $token = $client->getAccessToken();
        $client->setAccessToken($token);

        $channelsResponse = $youtube->channels->listChannels('snippet,contentDetails,statistics,status,brandingSettings', array(
            'mine' => 'true',
            'quotaUser' => $userId
        ));

        $videoResponse = $youtube->playlistItems->listPlaylistItems('snippet', array(
            'playlistId' => $channelsResponse['items'][0]['contentDetails']['relatedPlaylists']['uploads'],
            'maxResults'=> '50',
            'quotaUser' => $userId
        ));
        $videos = [];
        foreach($videoResponse['items'] as $video)
        {
            $videos[] = $video['snippet']['resourceId']['videoId'];
        }
        while(isset($videoResponse['nextPageToken']))
        {
            $videoResponse = $youtube->playlistItems->listPlaylistItems('snippet', array(
                'playlistId' => $channelsResponse['items'][0]['contentDetails']['relatedPlaylists']['uploads'],
                'maxResults'=> '50',
                'pageToken' => $videoResponse['nextPageToken']
            ));
            foreach($videoResponse['items'] as $video)
            {
                $videos[] = $video['snippet']['resourceId']['videoId'];
            }
        }

        print_r($videos);
    }

嗨,你解决问题了吗?不幸的是没有。在这种情况下,这样的决定是不存在的。我通过创建一组密钥并监控每个密钥的配额使用情况来解决这个问题。