简体   繁体   English

如何使用Google云端硬盘中的PHP SDK访问我自己的文件?

[英]How to get access to my own files using PHP SDK in Google Drive?

This is what I've tried: 这是我尝试过的:

$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");
}

This retrieved only one file ("application/pdf" with title "Getting started"), not my own files. 这仅检索了一个文件(标题为“入门”的“ application / pdf”),而不是我自己的文件。 What is my mistake? 我怎么了

The client is authenticating with credentials in the .json file, most likely. 客户端最有可能使用.json文件中的凭据进行身份验证。 Are those your accurate credentials, or a set of test credentials provided with the SDK? 这些是您的准确凭据还是SDK随附的一组测试凭据?

Disclaimer: I have never worked with the drive sdk, only suggesting what might be an issue here. 免责声明:我从未使用过驱动器sdk,只是建议这里可能存在问题。

Determine if the test-7b390c56695f.json is the client-secret.json produced in the Google Developer Console. 确定test-7b390c56695f.json是否为在Google开发者控制台中生成的client-secret.json

You have to be properly authenticated to be able to retrieve your own files. 您必须经过正确的身份验证才能检索自己的文件。 The PHP Quickstart is a good place to begin learning how the Drive API works. PHP快速入门是开始学习Drive API如何工作的好地方。 Once done, you can now check out on the proper authentication scopes you'll be needing for your application. 完成后,您现在可以签出应用程序所需的正确身份验证范围

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM