Google views - get photos details for a region
Asked Answered
E

1

16

Looking for a way to mimic Flickr API logic to use Google views.

On Flickr I can call the flickr.photos.search method and get all the photos for a specific location like so:

https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=cb33497ccae3482a7d5252f15b790fe3&woe_id=727232&format=rest&api_sig=bc7b1227243d969498f9d7643438f18f

The response:

<?xml version="1.0" encoding="utf-8" ?>
  <rsp stat="ok">
    <photos page="1" pages="7673" perpage="100" total="767266">
    <photo id="17856165012" owner="91887621@N04" secret="6d2acf3b87" server="7690" farm="8" title="Amsterdam Canal" ispublic="1" isfriend="0" isfamily="0" />
    <photo id="17830118816" owner="131827681@N05" secret="ee8b55fc5e" server="7756" farm="8" title="IMG_2209" ispublic="1" isfriend="0" isfamily="0" />
    <photo id="17668921970" owner="131827681@N05" secret="bd0061e638" server="8825" farm="9" title="IMG_2210" ispublic="1" isfriend="0" isfamily="0" />
    <photo id="17853550052" owner="131827681@N05" secret="c834e9a7eb" server="7738" farm="8" title="IMG_2212" ispublic="1" isfriend="0" isfamily="0" />
    <photo id="17856935911" owner="131827681@N05" secret="39be86bb4b" server="7723" farm="8" title="IMG_2213" ispublic="1" isfriend="0" isfamily="0" />
    <photo id="17233920844" owner="131827681@N05" secret="8be2333be3" server="7658" farm="8" title="IMG_2214" ispublic="1" isfriend="0" isfamily="0" />
    <photo id="17853542232" owner="131827681@N05" secret="8f19ee65c2" server="7747" farm="8" title="IMG_2215" ispublic="1" isfriend="0" isfamily="0" />
    <photo id="17856926911" owner="131827681@N05" secret="bc0fb6dbc1" server="7667"....

Then I call flickr.photos.getInfo for each photo id to get the photo info

The Response:

<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="ok">
  <photo id="17853542232" secret="8f19ee65c2" server="7747" farm="8" dateuploaded="1432037570" isfavorite="0" license="0" safety_level="0" rotation="90" originalsecret="7848968317" originalformat="jpg" views="2" media="photo">
    <owner nsid="131827681@N05" username="trashhunters" realname="Trash Hunters" location="" iconserver="7748" iconfarm="8" path_alias="trashhunters" />
    <title>IMG_2215</title>
    <description />
    <visibility ispublic="1" isfriend="0" isfamily="0" />
    <dates posted="1432037570" taken="2015-05-17 13:47:32" takengranularity="0" takenunknown="0" lastupdate="1432040217" />
    <editability cancomment="0" canaddmeta="0" />
    <publiceditability cancomment="1" canaddmeta="0" />
    <usage candownload="1" canblog="0" canprint="0" canshare="1" />
    <comments>0</comments>
    <notes />
    <people haspeople="0" />
    <tags>
      <tag id="131822341-17853542232-563433" author="131827681@N05" authorname="trashhunters" raw="blikje" machine_tag="0">blikje</tag>
      <tag id="131822341-17853542232-81138" author="131827681@N05" authorname="trashhunters" raw="fanta" machine_tag="0">fanta</tag>
    </tags>
    <location latitude="52.367408" longitude="4.862769" accuracy="16" context="0" place_id="xQ4tawtWUL1NrOY" woeid="727232">
      <locality place_id="xQ4tawtWUL1NrOY" woeid="727232">Amsterdam</locality>
      <county place_id="nmbnjNtQUL_iOTHdPg" woeid="12592040">Amsterdam</county>
      <region place_id="F86XYCBTUb6DPzhs" woeid="2346379">North Holland</region>
      <country place_id="Exbw8apTUb6236fOVA" woeid="23424909">Netherlands</country>
    </location>
    <geoperms ispublic="1" iscontact="0" isfriend="0" isfamily="0" />
    <urls>
      <url type="photopage">https://www.flickr.com/photos/trashhunters/17853542232/</url>
    </urls>
  </photo>
</rsp>

I'm interested in the longitude, latitude, time taken and user info. I've looked through the Google places API but couldn't find a way.

Update: just to be clear, I've found the place details request, on Google API but the photos result does not contain location or user data:

..."photos" : [
         {
            "height" : 2322,
            "html_attributions" : [
               "\u003ca href=\"//lh5.googleusercontent.com/-QO7PKijayYw/AAAAAAAAAAI/AAAAAAAAAZc/fTtRm3YH3cA/s100-p-k/photo.jpg\"\u003eWilliam Stewart\u003c/a\u003e"
            ],
            "raw_reference" : {
               "fife_url" : "https://lh3.googleusercontent.com/-7mKc4261Edg/VB01Tfy2OWI/AAAAAAAADII/BHs-SIudu64/k/"
            },
            "width" : 4128
         },...

Any advice would be appreciated :)

Everard answered 19/5, 2015 at 18:5 Comment(8)
The API calls are a little convoluted. You make a request by lat / long. You get a place or list of place depending on how specific you are about what you are looking for. Then you make an API call for the images, and then another API call for each image URL.Photoperiod
I'm using the older API which doesn't require API key BC the API keys are domain specific. The new API is better. But if you are closing out question, I'm 70% done, but noticed you have accepted an answer. LMK if you are still open to an implementation as an answer or are content with current answer.Photoperiod
Sure! I'll be glad to get another approach, thank you!Everard
Do you want the Google Panoramic street View, The G+ pics of local places, or (I suspect), both? Do you want all pics in bulk, or to choose place by place if they're relevant?Photoperiod
Ideally I would like all pictures of a country.Everard
@dave alperovich, Any luck hacking the solution? :)Everard
No, David Mulder's answer is correct. Everything you wanted was available, but there was indeed no way to access the G+ meta data like Picture Title, comments, etc. Google made some major releases in the past month directed at merging maps and G+, but they either haven't gotten to providing this info, or are uninterested in doing soPhotoperiod
One more thing, it seems that google stripped the location information from the response. check out this guy post :blog.thematicmapping.org/2014/08/…Everard
E
9

I have good news and bad news for you. The good news is that it's possible, the bad news is that there are a crazy amount of caveats and it's not guaranteed you will be able to get the info you wish for every photo.

Step 1: The user information

When you request place information from the place API you receive an array of photos. Each photo has an url, a width, a height and a html_attributions string. If my understanding is correct that last string will be empty if the owner of the establishment uploaded the photos himself, but in case it is third party content it will contain a link which you have to include in the page with user attribution. To use the first photo for Google HQ from your question we get the following information

{
  url: 'https://lh5.googleusercontent.com/-7mKc4261Edg/VB01Tfy2OWI/AAAAAAAADII/BHs-SIudu64/s0/20140109_152438.jpg',
  width: 2322,
  height: 4128,
  html_attributions: '<a href="https://plus.google.com/107252953636064841537">William Stewart</a>'
}

In the large majority of the cases (if not all) this will be a link to a Google Plus user account, from which we can extract the userId. In this case 107252953636064841537

Step 2: Finding the photo

Now, the logical next step would seem to go to the Google+ API, but it turns out that they still have not included a way to access Google+ Photos. Surprisingly enough however the Picasa Web API still is up and running and seems to still return up to date data. So next we can request all albums for this user through the following url using the userId we found above (Google has kindly used the same ids, or simply supports Google+ user ids).

https://picasaweb.google.com/data/feed/api/user/107252953636064841537

In there there is a single <entry> for each album the user has which contains the following

<feed>
   [...]
   <entry>
      [...]
      <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="https://picasaweb.google.com/data/feed/api/user/107252953636064841537/albumid/6061059278861279377" />
      [...]
   </entry>
</feed>

You would need to request every album feed to get a list of photos by requesting the url in the href field. This will return another xml document which contains the following information for each photo:

<entry>
  <id>https://picasaweb.google.com/data/entry/api/user/107252953636064841537/albumid/6061059278861279377/photoid/6061059282579110242</id>
  <published>2014-09-20T08:05:33.000Z</published>
  <updated>2014-10-08T20:11:49.889Z</updated>
  <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/photos/2007#photo" />
  <title type="text">20140109_152438.jpg</title>
  <summary type="text" />
  <content type="image/jpeg" src="https://lh3.googleusercontent.com/-7mKc4261Edg/VB01Tfy2OWI/AAAAAAAADII/BHs-SIudu64/20140109_152438.jpg" />
  <link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="https://picasaweb.google.com/data/feed/api/user/107252953636064841537/albumid/6061059278861279377/photoid/6061059282579110242" />
  <link rel="alternate" type="text/html" href="https://picasaweb.google.com/107252953636064841537/September20201402#6061059282579110242" />
  <link rel="http://schemas.google.com/photos/2007#canonical" type="text/html" href="https://picasaweb.google.com/lh/photo/CpdWkfaimetJbSbFK2cojdMTjNZETYmyPJy0liipFm0" />
  <link rel="self" type="application/atom+xml" href="https://picasaweb.google.com/data/entry/api/user/107252953636064841537/albumid/6061059278861279377/photoid/6061059282579110242" />
  <link rel="http://schemas.google.com/photos/2007#report" type="text/html" href="https://picasaweb.google.com/lh/reportAbuse?uname=107252953636064841537&amp;aid=6061059278861279377&amp;iid=6061059282579110242" />
  <gphoto:id>6061059282579110242</gphoto:id>
  <gphoto:version>7</gphoto:version>
  <gphoto:position>2.0</gphoto:position>
  <gphoto:albumid>6061059278861279377</gphoto:albumid>
  <gphoto:access>public</gphoto:access>
  <gphoto:width>4128</gphoto:width>
  <gphoto:height>2322</gphoto:height>
  <gphoto:size>1756108</gphoto:size>
  <gphoto:client />
  <gphoto:checksum />
  <gphoto:timestamp>1389241477000</gphoto:timestamp>
  <gphoto:imageVersion>3202</gphoto:imageVersion>
  <gphoto:commentingEnabled>true</gphoto:commentingEnabled>
  <gphoto:commentCount>0</gphoto:commentCount>
  <gphoto:streamId>cs_01_3c7bd15d390e38745feedfd0c8ec076f</gphoto:streamId>
  <gphoto:license id="0" name="All Rights Reserved" url="">ALL_RIGHTS_RESERVED</gphoto:license>
  <gphoto:shapes faces="done" />
  <exif:tags>
     <exif:fstop>2.2</exif:fstop>
     <exif:make>SAMSUNG</exif:make>
     <exif:model>GT-I9505</exif:model>
     <exif:exposure>0.030303031</exif:exposure>
     <exif:flash>false</exif:flash>
     <exif:focallength>4.2</exif:focallength>
     <exif:iso>80</exif:iso>
     <exif:time>1389281077000</exif:time>
     <exif:imageUniqueID>721da79fdf344aa70000000000000000</exif:imageUniqueID>
  </exif:tags>
  <media:group>
     <media:content url="https://lh3.googleusercontent.com/-7mKc4261Edg/VB01Tfy2OWI/AAAAAAAADII/BHs-SIudu64/20140109_152438.jpg" height="288" width="512" type="image/jpeg" medium="image" />
     <media:credit>William Stewart</media:credit>
     <media:description type="plain" />
     <media:keywords />
     <media:thumbnail url="https://lh3.googleusercontent.com/-7mKc4261Edg/VB01Tfy2OWI/AAAAAAAADII/BHs-SIudu64/s72/20140109_152438.jpg" height="41" width="72" />
     <media:thumbnail url="https://lh3.googleusercontent.com/-7mKc4261Edg/VB01Tfy2OWI/AAAAAAAADII/BHs-SIudu64/s144/20140109_152438.jpg" height="81" width="144" />
     <media:thumbnail url="https://lh3.googleusercontent.com/-7mKc4261Edg/VB01Tfy2OWI/AAAAAAAADII/BHs-SIudu64/s288/20140109_152438.jpg" height="162" width="288" />
     <media:title type="plain">20140109_152438.jpg</media:title>
  </media:group>
</entry>

Note how the src attribute of the <content> tag is equal to the url from the first API call, except for the sub domain which you should ignore (which is different because of load balancing). Also note how all available information about the photo is exposed in the xml document and how it contains all exif data which has been stripped from the photo itself. Obviously not all photos contain GPS information, and the above one is an example of that. If however a photo does contain GPS information it will be included in that document either in the exif data and/or in a <georss:where> tag.

Concluding

To find the information you're looking for you would need to loop through all the users albums and then search for a photo with a similar url to the one you received from the Google Places API. The biggest caveats are that it will only work for photos from Google+, that it requires a lot of requests and that the Picasa Web API is likely to be discontinued at some point, though at that point at least a part of its functionality will be ported to the Google+ Photos API (though Google is planning again to make Google Photos a standalone service, so in that case it might just be renamed). Either way, all considered I am surprised that it is possible at all as the Google Place API isn't made for all this, so in that sense you're quite lucky I guess.

Eleemosynary answered 21/5, 2015 at 20:46 Comment(14)
Thanks for the effort, still missing one step: get all photos for a region. Any idea how to do that?Everard
@ShlomiSchwartz Ah, well, Picasa Web API does not provide such functionality, so in that case I guess you have two options: Build your own index by crawling all Picasa Web Albums through the API or querying places through the Google Places API and then retrieving the associated photos as described. In the second case there is a relatively simple nearbysearch API call or in the javascript API the PlaceSearchRequest.Eleemosynary
Sorry, but this information is incorrect. They have in fact given access to photos. The API calls are a little tricky. 1st you have to pick the specific place, then you get make details request, then api call for each photo. And this is with the outdated API I'm using to create a Plunker. The new API is much better but it requires a Domain specific key.Photoperiod
@DaveAlperovich Please be clearer, which information is incorrect? Who has given access to which photos? And which API call would you wish to do for each photo? And what is a Plunker supposed to be?Eleemosynary
Good point. For example when you say they still have not included a way to access Google+ Photos. I made service.nearbySearch() with lat / lon to Google Places. I got back Info, about a place. I made a service.getDetails() request with the place ID to the API got an array of Image objects. I made a call to getUrl() on each of the images and got the image url'sPhotoperiod
When using lat / lon, there is the extra challenge of specifying a place. So a good implementation of the API should give the user a choice of places to choose, then make further requests against the API for the specific place chosen.Photoperiod
"To find the information you're looking for you would need to loop through all the users albums and then search for a photo with a similar url to the one you received from the Google Places API. The biggest caveat is that it will only work for photos from Google+, that it requires a lot of requests" is all verifiably untrue. I understand, you scanned the docs and got a quick idea of what is involved. I did too. But until you try to implement the API, you are very likely to be wrong. Especially since the documentation is shoddy.Photoperiod
To be clear, I chose to use the old API. It doesn't require an API key. and It doesn't have call limits (because no identifier key). I wouldn't be able to use the new API with Plnkr. API Key's are tied to specific domains.Photoperiod
"Either way, all considered I am surprised that it is possible at all as the Google Place API isn't made for all this, so in that sense you're quite lucky I guess" here again, you're not right. Without implementing the solution, you wouldn't have opportunity to realize where your assumptions fell short. But most of your conclusions are wrong. They are reasonable, but, inaccurate.Photoperiod
You really haven't heard of plnkr.co? You seem to have so much JS experience. Think of Fiddle, but much better.Photoperiod
Wow, that's a lot of comments: So, I will address your comments from top to bottom. First of all, doing an API call to Google Places has nothing to do with doing an API call to Google+ Photos. Google Places is about well, businesses and the like and yeah, as I describe in the first section an API call to them will indeed return an array of photos about the place.Eleemosynary
And regarding the rest: I actually did all the API calls. Where do you think I found the relevant replies I quoted in the answer? The only difference is that I did all the processing by hand which would be scripted in a final implementation. I literally found the requested information about the photo mentioned in the question and I described each and every step to allow the automation of finding that information. First time round I just did it through the web interfaces, and afterwards I found the same information through the Place API and Picasa Web API.Eleemosynary
And I feel bad for telling you this, but Plunker seriously isn't that big. It seems to be quite popular with the Angular.js crowd though, but despite everything that's just one of many groups in the JS world. And either way, if you reply, please just take it to chat ;-) .Eleemosynary
Let us continue this discussion in chat.Photoperiod

© 2022 - 2024 — McMap. All rights reserved.