查询附近的酒店
2024-07-19 11:27分类: 成都民宿 阅读:
输入您的位置信息,我们将为您提供附近的酒店信息。
查询结果";echo "
";foreach ($hotels as $hotel) {echo "
-
$hotel->name
";echo "
-
$hotel->address
";echo "
-
$hotel->phone
";echo "
-
$hotel->website
";echo "
";}echo "
";} else {echo "抱歉,在指定范围内没有找到酒店。";}}// 获取附近的酒店
function get_nearby_hotels($address, $radius) {// 使用 Google Places API 查询附近的酒店
$url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=$address&radius=$radius&type=hotel&key=YOUR_API_KEY";$json = file_get_contents($url);$data = json_decode($json);// 从结果中提取酒店信息$hotels = array();if (isset($data->results)) {foreach ($data->results as $result) {$hotel = new stdClass();$hotel->name = $result->name;$hotel->address = $result->formatted_address;$hotel->phone = $result->formatted_phone_number;$hotel->website = $result->website;$hotels[] = $hotel;}}return $hotels;
}
?>
郑重声明:部分文章来源于网络,仅作为参考,如果网站中图片和文字侵犯了您的版权,请联系我们处理!
上一篇:成都到稻城亚丁中途住宿
下一篇:成都游玩住哪性价比高
相关推荐