Shl*_*rtz 18 javascript api google-maps flickr google-places-api
正在寻找一种模仿Flickr API逻辑来使用Google视图的方法.
在Flickr上,我可以调用该flickr.photos.search方法并获取特定位置的所有照片,如下所示:
响应:
<?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"....
Run Code Online (Sandbox Code Playgroud)
然后我打电话flickr.photos.getInfo给每张照片ID以获取照片信息
响应:
<?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>
Run Code Online (Sandbox Code Playgroud)
我对经度,纬度,时间和用户信息感兴趣.我查看了Google Places API但找不到方法.
更新: 为了清楚起见,我在Google API上找到了地点详细信息请求,但照片结果中不包含位置或用户数据:
..."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
},...
Run Code Online (Sandbox Code Playgroud)
任何意见,将不胜感激 :)
我有好消息和坏消息.好消息是,这是可能的,坏消息是有一些疯狂的警告,并且不能保证你能够获得你想要的每张照片的信息.
当您从地方API请求地点信息时,您会收到一系列照片.每张照片都有一个url,一个width,一个height和一个html_attributions字符串.如果我的理解是正确的,如果企业的所有者自己上传了照片,那么最后一个字符串将是空的,但是如果它是第三方内容,它将包含您必须包含在具有用户归属的页面中的链接.要从您的问题中使用Google HQ的第一张照片,我们会获得以下信息
{
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>'
}
Run Code Online (Sandbox Code Playgroud)
在绝大多数情况下(如果不是全部),这将是指向Google Plus用户帐户的链接,我们可以从中提取userId.在这种情况下107252953636064841537
现在,合乎逻辑的下一步似乎是转到Google+ API,但事实证明他们仍未提供访问Google+照片的方法.令人惊讶的是,Picasa Web API仍然正常运行,似乎仍然可以返回最新数据.接下来我们可以使用userId上面找到的以下网址通过以下网址请求此用户的所有相册(Google已使用相同的ID,或仅支持Google+用户ID).
https://picasaweb.google.com/data/feed/api/user/107252953636064841537
在那里<entry>,用户拥有的每张专辑都有一个包含以下内容的专辑
<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>
Run Code Online (Sandbox Code Playgroud)
您需要通过在href字段中请求网址来请求每个相册Feed以获取照片列表.这将返回另一个xml文档,其中包含每张照片的以下信息:
<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&aid=6061059278861279377&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>
Run Code Online (Sandbox Code Playgroud)
请注意标记的src属性如何<content>等于url第一个API调用,除了您应忽略的子域(由于负载平衡而不同).另请注意有关照片的所有可用信息是如何在xml文档中公开的,以及它如何包含exif从照片本身中剥离的所有数据.显然并非所有照片都包含GPS信息,而上述照片就是一个例子.但是,如果照片确实包含GPS信息,则该照片将包含在exif数据和/或<georss:where>标签中.
要查找您要查找的信息,您需要遍历所有用户相册,然后搜索与url您从Google Places API收到的相似的照片.最大的警告是,它只适用于来自Google+的照片,它需要大量请求,并且Picasa Web API可能会在某个时候停止使用,但此时至少部分功能将被移植到Google+照片API(虽然Google计划再次将Google相册设为独立服务,因此在这种情况下可能只是重命名).无论哪种方式,所有人都认为我很惊讶,因为谷歌广告API不是为所有这些而制作的,所以从这个意义上说你很幸运.
| 归档时间: |
|
| 查看次数: |
749 次 |
| 最近记录: |