相关疑难解决方法(0)

我无法使用php在我的Google云端硬盘中看到通过api创建的文件和文件夹

我正在尝试使用谷歌驱动器api创建文件夹.我能够在最后得到文件ID.但我无法在谷歌驱动器中的文件夹.看来有些许可问题?

$scopes = array(
    'https://www.googleapis.com/auth/drive',
    'https://www.googleapis.com/auth/drive.appdata','https://www.googleapis.com/auth/drive.apps.readonly',
    'https://www.googleapis.com/auth/drive.metadata','https://www.googleapis.com/auth/drive.file',
    'https://www.googleapis.com/auth/drive.readonly','https://www.googleapis.com/auth/drive.photos.readonly'
);
$creds = new Google_Auth_AssertionCredentials(
    $serviceAccountName,
    $scopes,
    file_get_contents($keyFile)
);
$client = new Google_Client();
$client->setApplicationName($appName);
$client->setClientId($clientId);
$client->setAssertionCredentials($creds);
$service = new Google_Service_Drive($client);
$fileMetadata = new Google_Service_Drive_DriveFile(array(
  'name' => 'Invoices',
  'permissions' => array('type'=>'anyone','role'=>'reader','allowFileDiscovery'=>1),

  'mimeType' => 'application/vnd.google-apps.folder'));
$file = $service->files->create($fileMetadata, array());

printf("File ID: %s\n", $file->id);
Run Code Online (Sandbox Code Playgroud)

php google-drive-api google-admin-sdk

11
推荐指数
1
解决办法
1463
查看次数

标签 统计

google-admin-sdk ×1

google-drive-api ×1

php ×1