title: Google Drive PHP Client Library Retrieve a list of File resources
body: <p>I try to use this function in my code: <a href="https://developers.google.com/drive/v2/reference/files/list" rel="nofollow noreferrer">https://developers.google.com/drive/v2/reference/files/list</a></p>
  
  <p>Here below:</p>
  
  <pre><code>/**
   * 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-&gt;files-&gt;listFiles($parameters);
  
        array_merge($result, $files-&gt;getItems()); // &lt;---- Exception is throw there !
        $pageToken = $files-&gt;getNextPageToken();
      } catch (Exception $e) {
        print "An error occurred: " . $e-&gt;getMessage();
        $pageToken = NULL;
      }
    } while ($pageToken);
    return $result;
  }
  </code></pre>
  
  <p>But i got this error:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>Thee array seems to be empty may be but it shouldn't be:</p>
  
  <pre><code>Array
  (
      [kind] =&gt; drive#fileList
      [etag] =&gt; "WtRjAPZWbDA7_fkFjc5ojsEvE7I/lmSsH-kN3I4LpwShGKUKAM7cxbI"
      [selfLink] =&gt; https://www.googleapis.com/drive/v2/files
      [items] =&gt; Array
          (
          )
  
  )
  </code></pre>