Receive google drive notification

0

Is it possible to configure the google drive for my client to receive an email when the drive gets one day without sharing any files? And I'm looking for how to integrate the drive in my system with PHP, for there my client have the reports of shares, I've seen something similar, but I did not find content about it.

    
asked by anonymous 18.07.2016 / 15:16

1 answer

0

The Google Drive API has support for PHP. You can use it to query through an asynchronous task written in PHP to check daily directory changes and send emails according to your rules. This API will also serve to integrate with your system.

In this article from Google, you can follow the step-by-step how to use the API.

See the following example, contained in the link given above:

// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Drive($client);

// Print the names and IDs for up to 10 files.
$optParams = array(
  'pageSize' => 10,
  'fields' => "nextPageToken, files(id, name)"
);
$results = $service->files->listFiles($optParams);

if (count($results->getFiles()) == 0) {
  print "No files found.\n";
} else {
  print "Files:\n";
  foreach ($results->getFiles() as $file) {
    printf("%s (%s)\n", $file->getName(), $file->getId());
  }
}

I do not understand if what you need is to send email only in the absence of file sharing, or it is absence in creating or modifying the file, but for both, you can do by passing the correct parameters in $ optParams ['fields'], they are modifiedDate and sharedWithMeDate . Then you'll get the results and send the emails you need.

In this link you can use Try it at the bottom of the page to check the extra parameters available in the listFiles method call.

    
18.07.2016 / 18:35