PHP code example of soramugi / google-drive-client-php

1. Go to this page and download the library: Download soramugi/google-drive-client-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

soramugi / google-drive-client-php example snippets



ent = new Soramugi\GoogleDrive\Client;

$client->setClientId('your client id');
$client->setClientSecret('your client secret');

$token = '{"access_token":"your_access_token","token_type":"Bearer","expires_in":3600,"refresh_token":"your_refresh_token","created":0000000000}';
$client->setAccessToken($token);


$files = new Soramugi\GoogleDrive\Files($client);

foreach ($files->listFiles()->getItems() as $item) {
    if (!$item->getLabels()->getTrashed()) {
        echo "file : {$item->getTitle()}\n";
        echo "{$item->getId()}\n";
    }
}

$file = new Soramugi\GoogleDrive\Spreadsheet();
$file->setClient($client);
$file->setTitle('test file '. time());
$file->setDescription('test description');

$data = "foo,var\nhi";
$createdFile = $file->insert($data);
echo $createdFile->getTitle() . "\n";