2013-05-07 169 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