如何在 Google Drive 中使用 PHP SDK 访问我自己的文件?
How to get access to my own files using PHP SDK in Google Drive?
这是我试过的:
$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 提供的一组测试凭据?
免责声明:我从未使用过驱动器 sdk,只是建议这里可能存在的问题。
确定 test-7b390c56695f.json
是否是 Google 开发者控制台中生成的 client-secret.json
。
您必须经过适当的身份验证才能检索自己的文件。 PHP Quickstart is a good place to begin learning how the Drive API works. Once done, you can now check out on the proper authentication scopes 您的申请将需要。
这是我试过的:
$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 提供的一组测试凭据?
免责声明:我从未使用过驱动器 sdk,只是建议这里可能存在的问题。
确定 test-7b390c56695f.json
是否是 Google 开发者控制台中生成的 client-secret.json
。
您必须经过适当的身份验证才能检索自己的文件。 PHP Quickstart is a good place to begin learning how the Drive API works. Once done, you can now check out on the proper authentication scopes 您的申请将需要。