Receive notification from google drive

Asked

Viewed 43 times

0

Is it possible to set up google drive for my client to receive an email when the drive goes one day without sharing any files? And I’m looking for how to integrate the drive in my system with PHP, so that my client has the sharing reports, I’ve seen something similar, but I haven’t found any content about it.

  • Alisson, explain your problem better, not understand it properly, what do you mean, go a day without sharing? And could you add what you tried to do? Thank you

1 answer

0

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

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

See the following example, contained in the link 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 did not understand if what you need is to send email only in the absence of file sharing, or it is absence in the creation or modification of the file, but for both, you can do by passing the correct parameters in $optParams['Fields'], are they modifiedDate and sharedWithMeDate. Then you handle the result and send the emails you need.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.