我尝试在我的代码中使用此功能:https ://developers.google.com/drive/v2/reference/files/list
在下面:
/**
* Retrieve a list of File resources.
*
* @param apiDriveService $service Drive API service instance.
* @return Array List of File resources.
*/
function retrieveAllFiles($service) {
$result = array();
$pageToken = NULL;
do {
try {
$parameters = array();
if ($pageToken) {
$parameters['pageToken'] = $pageToken;
}
$files = $service->files->listFiles($parameters);
array_merge($result, $files->getItems()); // <---- Exception is throw there !
$pageToken = $files->getNextPageToken();
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
$pageToken = NULL;
}
} while ($pageToken);
return $result;
}
但我得到了这个错误:
致命错误:在第 115 行调用 C:\Program Files (x86)\EasyPHP-5.3.6.1\www\workspace\CPS\class\controller\CtrlGoogleDrive.php 中非对象的成员函数 getItems()
你的数组似乎是空的,但它不应该是:
Array
(
[kind] => drive#fileList
[etag] => "WtRjAPZWbDA7_fkFjc5ojsEvE7I/lmSsH-kN3I4LpwShGKUKAM7cxbI"
[selfLink] => https://www.googleapis.com/drive/v2/files
[items] => Array
(
)
)