I try to use this function in my code: https://developers.google.com/drive/v2/reference/files/list
Here below:
/**
* 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;
}
But i got this error:
Fatal error: Call to a member function getItems() on a non-object in C:\Program Files (x86)\EasyPHP-5.3.6.1\www\workspace\CPS\class\controller\CtrlGoogleDrive.php on line 115
Thee array seems to be empty may be but it shouldn't be:
Array
(
[kind] => drive#fileList
[etag] => "WtRjAPZWbDA7_fkFjc5ojsEvE7I/lmSsH-kN3I4LpwShGKUKAM7cxbI"
[selfLink] => https://www.googleapis.com/drive/v2/files
[items] => Array
(
)
)