/**
* Google Places API Web Service
* Place Details
*
* @param string $placeId
* @return array
* @see https://developers.google.com/places/web-service/details
*/
private function placeDetails($placeId)
{
$curl = new Curl();
$curl->setTimeout(15);
$curl->setOpt(CURLOPT_SSL_VERIFYHOST, false);
$curl->setJsonDecoder(function ($string) {
return json_decode($string, true);
});
$curl->get(Config::get('googleplaces.api_details'), ['key' => Config::get('googleplaces.key'), 'language' => 'zh-CN', 'placeid' => $placeId]);
if ($curl->error) {
return ['status' => $curl->errorMessage];
} else {
$response = $curl->response;
foreach ($response['result']['address_components'] as $i => $item) {
$response['result']['address_components'][$item['types'][0]] = $item;
unset($response['result']['address_components'][$i]);
}
return $response;
}
}