2013-05-07 2 views
4

Google지도 API에서 리뷰를 가져와야합니다. 자세한 내용은이 페이지에 있습니다.Google지도에서 리뷰보기 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 플러스 페이지에서이 매개 변수 값을 찾는 방법에 대해 설명합니다.

답변

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

Google 리뷰를 가져 오는 데는 장소에 대한 참조 ID가 필요합니다.이 참조 키를 얻으려면 Google 장소 검색 API 요청을 사용할 수 있습니다.

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

그 응답은 당신이 당신의 요구에 사용할 수있는 참조 ID를해야합니다. 내가 PHP를 통해 만든

<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); 

지금이 URL과 같이 호출하면 참조 키를 사용하여 원래의 결과를 얻을.

그런 다음 원하는 구문 분석 :

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

그것이 도움이 될 것입니다 희망 당신

*** 참고 : 위치 = 38.908310, -104.784035이 var에 당신이 그것을해야합니다 자동 없습니다.

+0

thankas abbas 내가 작년에 내 probleam을 해결했습니다 :) –

+0

얼마나 많은 리뷰를 돌려 줄까요? – Nico

+0

문서에 따라 최대 5 개까지 : '리뷰 [] 최대 5 개 리뷰의 JSON 배열. 장소 세부 정보 요청에 언어 매개 변수가 지정된 경우 지역 정보 서비스는 해당 언어로 작성된 리뷰를 선호하도록 결과를 조정합니다 .' – SHG

관련 문제