Reputation: 8291
I have the following code (from Google Doc Api
resources) to fetch changes from google drive. However, I want to retrieve the changes made by each user on a specific google doc. Is there a way to achieve this?
var _driveService = GetDriveServiceInstance();
var requestxx = _driveService.Changes.GetStartPageToken();
var response = requestxx.Execute();
var savedStartPageToken = response.StartPageTokenValue;
// Begin with our last saved start token for this user or the
// current token from GetStartPageToken()
string pageToken = savedStartPageToken;
while (pageToken != null)
{
var request = _driveService.Changes.List(pageToken);
request.Spaces = "drive";
var changes = request.Execute();
foreach (var change in changes.Changes)
{
// Process change
Console.WriteLine("Change found for file: " + change.FileId);
}
if (changes.NewStartPageToken != null)
{
// Last page, save this token for the next polling interval
savedStartPageToken = changes.NewStartPageToken;
}
pageToken = changes.NextPageToken;
}
Upvotes: 6
Views: 258
Reputation: 19319
I think the best way would be using Google Drive Activity API, which can provide more information on changes made to specific files. By calling activity.query you can get all past activity from a certain file, including information on the user that's behind each activity. Using this response, you could count the number of changes made by each user.
Another way, albeit incomplete, would be getting the list of Revisions of the file and then getting lastModifyingUser
from each revision. As you said, though, a revision might include many changes, so the retrieved data could be incomplete.
Also, if you consider it would be useful for Drive API to provide that level of detail regarding changes made to files, you could file a feature request in Issue Tracker.
I hope this is of any help.
Upvotes: 5