Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.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
如何在Google Drive中使用PHP SDK访问我自己的文件?_Php_Google Drive Api - Fatal编程技术网

如何在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如何工作的好地方。一旦完成,您现在就可以查看应用程序所需的正确选项