Google drive api 使用Google Drive API v3 PHP按id获取文件大小

Google drive api 使用Google Drive API v3 PHP按id获取文件大小,google-drive-api,Google Drive Api,我需要得到的文件大小由id与谷歌驱动器API v3和php。 我使用google drive API客户端库v3。我可以连接到谷歌磁盘,但我不知道如何通过其id获取文件大小。对不起,这只是一个不眠之夜 $drive = new Google_Service_Drive($client); $file_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; $optpParam

我需要得到的文件大小由id与谷歌驱动器API v3和php。
我使用google drive API客户端库v3。我可以连接到谷歌磁盘,但我不知道如何通过其id获取文件大小。

对不起,这只是一个不眠之夜

            $drive = new Google_Service_Drive($client);
            $file_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

            $optpParams = array(
                'fields' => "size"
                );
                
            $response = $drive->files->get($file_id, $optpParams);
            echo $response->size;