Google drive api 我的谷歌驱动器中的文件列表

Google drive api 我的谷歌驱动器中的文件列表,google-drive-api,google-apis-explorer,Google Drive Api,Google Apis Explorer,我正在编写PHP脚本,从我的谷歌驱动器文件夹中获取文件,并在我的网站上用下载链接列出这些文件的列表,但找不到从我的文件夹中获取文件的解决方案。我找到的每个解决方案都需要用户注册,即查看页面并从他的谷歌驱动器获取文件列表。有人能帮我解决这个问题吗 这是我的密码 function printFilesInFolder($service, $folderId) { $pageToken = NULL; do { try { $parameters = array();

我正在编写PHP脚本,从我的谷歌驱动器文件夹中获取文件,并在我的网站上用下载链接列出这些文件的列表,但找不到从我的文件夹中获取文件的解决方案。我找到的每个解决方案都需要用户注册,即查看页面并从他的谷歌驱动器获取文件列表。有人能帮我解决这个问题吗

这是我的密码

function printFilesInFolder($service, $folderId) {
  $pageToken = NULL;
  do {
    try {
      $parameters = array();
       $parameters = array(
        'q' => "'0B5NCdsbrL1VfQ00xY3pFS3BtOE0' in parents"
        );     
  $children = $service->files->listFiles($parameters);
  var_dump($children);
  foreach ($children->getFiles() as $child) {
    print 'File Id: ' . $child->getId();
  }
  $pageToken = $children->getNextPageToken();
} catch (Exception $e) {
  print "An error occurred: " . $e->getMessage();
  $pageToken = NULL;
}
  } while ($pageToken);
}

$client = new Google_Client();
$client->setApplicationName("Web client 1");
$client->setClientId('CLIENTID');
$client->setClientSecret('SECRET');
$client->setScopes(array('https://www.googleapis.com/auth/drive.file'));
$client->setRedirectUri('http://localhost/googledrive/drive/drive.php');

if (isset($_GET['code']) || (isset($_SESSION['access_token']) && $_SESSION['access_token'])) {
if (isset($_GET['code'])) {
    $client->authenticate($_GET['code']);
    $_SESSION['access_token'] = $client->getAccessToken();
} else
    $client->setAccessToken($_SESSION['access_token']);
$service = new Google_Service_Drive($client);
$ret = printFilesInFolder($service,"FOLDERID");
} else {
    $authUrl = $client->createAuthUrl();
    header('Location: ' . $authUrl);
    exit();
}
但我仍然没有得到正确的数据


第二个想法是,我想在每次刷新页面时都不需要验证,但我不知道怎么做。

使用谷歌官方文档来做这件事,我已经编辑了我的问题。不能使用v2 API,但在v3和那里我不能像v2 API那样使用listChildren()并猜测做了什么错误。请尝试使用来熟悉响应的格式。同样在“字段查询”中,应为返回的方法指定参数