How to use GeoNames Web Services using PHP

不打扰是莪最后的温柔 提交于 2019-12-11 17:38:13

问题


I have read this post and it looks very promising. However, the answer does not go in detail with regards the implementation.

Basically, given the latitude and longitude, how can I use the GeoNames Web Service to get the country. I would like the returned result to be stored in a variable so that I can then continue working with it as I wish.

Thanks in advance


回答1:


Do you have to use javascript for that? Geonames doesn't seem to offer a javascript api for doing your exact query (see here: http://www.geonames.org/export/JSON-webservices.html). And remote file fetching via javascript is not a joy.

If you could use php for that, it would be as easy as

$country = file_get_contents("http://ws.geonames.org/countryCode?lat=49.03&lng=10.2");


来源:https://stackoverflow.com/questions/13370421/how-to-use-geonames-web-services-using-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!