2013-05-07 171 views
4

我必须从谷歌地图API获得评论。细节在这个页面上。从谷歌地图获取评论api

https://developers.google.com/places/documentation/details#PlaceDetailsResults

细节将会从该页面获取: -

https://maps.googleapis.com/maps/api/place/details/json?reference=CmRYAAAAciqGsTRX1mXRvuXSH2ErwW-jCINE1aLiwP64MCWDN5vkXvXoQGPKldMfmdGyqWSpm7BEYCgDm-iv7Kc2PF7QA7brMAwBbAcqMr5i1f4PwTpaovIZjysCEZTry8Ez30wpEhCNCXpynextCld2EBsDkRKsGhSLayuRyFsex6JA6NPh9dyupoTH3g&sensor=true&key=AddYourOwnKeyHere

我的问题是我无法找到是什么要求参考。以及如何从我的Google plus页面找到此参数值。

回答

2

最近的一个办法做到这一点:

https://maps.googleapis.com/maps/api/place/details/json?placeid={place_id}&key={api_key}

响应:

{ 
    "html_attributions": [], 
    "result": { 
    ... 
    "rating": 4.6, 
    "reviews": [ 
     { 
     "author_name": "John Smith", 
     "author_url": "https://www.google.com/maps/contrib/106615704148318066456/reviews", 
     "language": "en", 
     "profile_photo_url": "https://lh4.googleusercontent.com/-2t1b0vo3t-Y/AAAAAAAAAAI/AAAAAAAAAHA/0TUB0z30s-U/s150-c0x00000000-cc-rp-mo/photo.jpg", 
     "rating": 5, 
     "relative_time_description": "in the last week", 
     "text": "Great time! 5 stars!", 
     "time": 1508340655 
     } 
    ] 
    } 
} 

评论仅限5份最新版本。

4

对于获取谷歌审查,你需要参考编号的地方。为了得到这个引用密钥,你可以使用谷歌地方搜索API请求。

https://maps.googleapis.com/maps/api/place/textsearch/xml?query=restaurants+in+bangalore&sensor=true&key=AddYourOwnKeyHere

它的反应将有参考编号,你可以在你的请求中使用。

<PlaceSearchResponse> 
    <status>OK</status> 
    <result> 
    <name>Koshy's Restaurant</name> 
    <type>bar</type> 
    <type>restaurant</type> 
    <type>food</type> 
    <type>establishment</type> 
    <formatted_address> 
    39, St Marks Road,Shivajinagar,Bangalore, Karnataka, 560001, India 
    </formatted_address> 
    <geometry> 
    <rating>3.7</rating> 
    <icon> 
    http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png 
    </icon> 
    **<reference>** 
    CnRwAAAA1z8aCeII_F2wIVcCnDVPQHQi5zdd-3FsDl6Xhb_16OGrILvvvI4X4M8bFk2U8YvuDCKcFBn_a2rjvYDtvUZJrHykDAntE48L5UX9hUy71Z4n80cO7ve_JXww6zUkoisfFnu6jEHcnKeeTUE42PCA4BIQGhGz0VrXWbADarhKwCQnKhoUOR-Xa9R6Skl0TZmOI4seqt8rO8I 
    **</reference>** 
    <id>2730db556ca6707ef517e5c165adda05d2395b90</id> 
    <opening_hours> 
    <open_now>true</open_now> 
    </opening_hours> 
    <html_attribution> 
    <a href="https://plus.google.com/116912222767108657277">Ujaval Gandhi</a> 
    </html_attribution> 
    </photo> 
    </result> 
2
$reqUri = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?key='.YOURSERVERKEY; 
$reqUri .= '&sensor=false&radius=500'; 
$reqUri .= '&location=38.908310,-104.784035&name='.urlencode(LOCATION NAME); 
$reqUri .= '&keyword='.urlencode(WEBSITE PHONE); 

我做它通过PHP,现在这样调用URL,你会得到参考键原来的结果。

然后分析它想:

$data = cURL($reqUri); 
$data = json_decode($data); 
echo $data ->results[0]->reference; 

希望它会帮助你

***注:位置= 38.908310,-104.784035这个变种是不是汽车,你必须拥有它。

+0

thankas阿巴斯我去年解决了我的疑难问题:) – 2014-03-19 05:52:48

+0

它会返回多少评论? – Nico 2016-07-18 21:34:14

+0

根据文档最多5个: '*评论[]一个最多5条评论的JSON数组。如果地方详情请求中指定了语言参数,则地方信息服务会将结果偏向于优先选择以该语言撰写的评论 – SHG 2017-03-25 03:46:25