Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After leaving this for a few months and coming back to it I finally got the method you were looking for, although i used Google's own class: </p> <p>The method is roughly the same; </p> <p>First call the class with <code>$this-&gt;client = new Google_Client();</code></p> <p>Then set all the metadata required to get the response for a specific client, set the scopes and set the access type:</p> <pre><code> // Get your credentials from the APIs Console $this-&gt;client-&gt;setClientId($this-&gt;client_id); $this-&gt;client-&gt;setClientSecret($this-&gt;client_secret); $this-&gt;client-&gt;setRedirectUri($this-&gt;redirect_uri); $this-&gt;client-&gt;setScopes(array('https://www.googleapis.com/auth/drive ','https://www.googleapis.com/auth/drive.file' )); $this-&gt;client-&gt;setAccessType("offline"); </code></pre> <p>Then finally get your stored access token (in database or stored in session) and use <code>Google_DriveService($this-&gt;client)</code> and these functions within the class to perform the listing of files: </p> <pre><code>try{ $json = json_encode($this-&gt;loadAccessTokenFromDB()); $this-&gt;client-&gt;setAccessToken($json); $this-&gt;client-&gt;setUseObjects(true); $service = new Google_DriveService($this-&gt;client); $parameters = array(); $parameters['q'] = " FullText contains '" . $searchString . "'"; $files = $service-&gt;files-&gt;listFiles($parameters); $ourfiles = $files-&gt;getItems(); $fileArray = array(); foreach ( $ourfiles as $file ) { $fileArray[] = array( 'title' =&gt; $file-&gt;getTitle(), 'id' =&gt; $file-&gt;getID(), 'created' =&gt; $file-&gt;getCreatedDate(), 'embedlink' =&gt; $file-&gt;getEmbedLink(), 'exportlinks' =&gt; $file-&gt;getExportLinks(), 'thumblink' =&gt; $file-&gt;getThumbnailLink(), 'mimeType' =&gt; $file-&gt;getMimeType(), 'webContentLink' =&gt; $file-&gt;getWebContentLink(), 'alternateLink' =&gt; $file-&gt;getAlternateLink(), 'permissions' =&gt; $file-&gt;getUserPermission() ); } //$this-&gt;mimeType = $file-&gt;getMimeType(); $this-&gt;documents-&gt;load($fileArray); if ($fileArray["id"] !== "") { $this-&gt;documents-&gt;firstRow(); return; } } catch(Google_AuthException $e) { print $e-&gt;getMessage(); } return; } </code></pre> <p>I was also doing testing on search strings that could be used, from what i managed to get tested, the string must be a string with no breaks and it will search for anything that contains that specific string of characters, e.g. </p> <p><code>foo</code> would give documents containing words like: <code>foo</code> <code>foobar</code> etc. but wouldent find <code>foo bar</code> so you must be careful, ideally you should be looking to have a specific unique string to search for if it is specific docs for a user or anything, </p> <p>Thanks again.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload