大家有没有办法在页面加载时从 URL 中获取城市名称,然后返回它所属的国家/地区?
假设这是我的网址:site.com/sevilla_r
如何在页面加载时返回西类牙语并将其显示在页面内容中?
附注
如果是一个国家,那就什么也不做!
最佳答案
您可以使用 Google geocade API
这将返回国家/地区名称、邮政编码、经纬度等
--编辑--
这就是我的实现方式
$url = 'https://maps.googleapis.com/maps/api/geocode/json?address=shimla&key=';
$json = file_get_contents($url);
print_r($json);
关于javascript - 从城市返回国家名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39660923/