I am trying to make the following workflow:
- Take a picture with iphone
- Google photos app automatically uploads the photo to my Google drive
- Run PHP script which will loop all files and print geolocation metadata
This is what I have done so far:
- Install the app and go to settings -> Backup and synchronization. Enable Backup and synchronization and choose your google account.
- Take a picture and go to Google photos app and check the new photo is present. Press on the photo to make it full screen. Press (i) for information and check that latitude and longitude is present.
- Go to https://developers.google.com/drive/v3/web/quickstart/php and follow the guide. Replace the bottom 8 lines with the following code:
if (count($results->getFiles()) == 0) {
print "No files found.\n";
}
else {
print "Files:\n";
foreach ($results->getFiles() as $file) {
print_r('-------------------------------');
printf("%s (%s)\n", $file->getName(), $file->getId());
$metadata = $file->getImageMediaMetadata();
if($metadata) {
print_r($metadata);
$location = $metadata->getLocation();
print_r("longitude: " . $location->getLongitude() . "\n");
print_r("latitude: " . $location->getLatitude() . "\n");
}
else {
print_r("no metadata\n");
}
}
}
I never get any metadata for the photos even though I can see it in my google photos app and google drive in the browser.
I then tried to go to https://developers.google.com/drive/v3/reference/files/get and use the fileID from one of the photos that was printed from code above that I knew had metadata. I got reponse 200 back and the follwing data:
{
"kind": "drive#file",
"id": "1Ngr32mjIDSg2i-UFq2jdi3syj6MkD7ZNEQ",
"name": "IMG_0481.JPG",
"mimeType": "image/jpeg"
}
Again without the geolocation metadata.
Can anybody point me in the right direction?