如何在Google Drive中使用PHP SDK访问我自己的文件?
这就是我尝试过的:如何在Google Drive中使用PHP SDK访问我自己的文件?,php,google-drive-api,Php,Google Drive Api,这就是我尝试过的: $client = new Google_Client(); $client->setAuthConfig(Mage::getBaseDir('etc') . '/test-7b390c56695f.json'); $client->setScopes(Google_Service_Drive::DRIVE); $client->setApplicationName('artsdecors-test'); $this->service = new Go
$client = new Google_Client();
$client->setAuthConfig(Mage::getBaseDir('etc') . '/test-7b390c56695f.json');
$client->setScopes(Google_Service_Drive::DRIVE);
$client->setApplicationName('artsdecors-test');
$this->service = new Google_Service_Drive($client);
foreach ($files as $file) {
echo($file->getMimeType() . "\n");
}
这只检索到一个文件(“application/pdf”,标题为“Getting started”),而不是我自己的文件。我的错误是什么?客户端很可能正在使用.json文件中的凭据进行身份验证。这些是您的准确凭据,还是SDK提供的一组测试凭据
免责声明:我从未使用过drive sdk,只是建议这里可能存在的问题。确定test-7b390c56695f.json是否是在Google开发者控制台中生成的
客户端机密.json
您必须经过正确的身份验证才能检索自己的文件。是开始学习驱动器API如何工作的好地方。一旦完成,您现在就可以查看应用程序所需的正确选项