I build this demo on the framework named ThinkPHP5.
I registered a free account at https://openweathermap.org
this repo has all file that needed, it just deploy to EB.
- get city list
(http://codetest-weather-api.ap-northeast-1.elasticbeanstalk.com/api/weather/getCitys)
- get weather
(http://codetest-weather-api.ap-northeast-1.elasticbeanstalk.com/api/weather/getWeather/cityCode/1)
cityCode = 1 means get weather of Sydney.
- the frontend
(http://codetest.ap-northeast-1.elasticbeanstalk.com/#/weather)
modify the config file at : /application/extra/Citys.php add a new city. then to query the city id at https://openweathermap.org
- downloads a json file about all city in the world (http://bulk.openweathermap.org/sample/city.list.json.gz)
- search the city by name and what country it belongs to.
- get the id , write it into another config file named WeatherApi.php, map the city code and the city id!
Yes! I make the adapter as a plugin mode, just need to config api info, and write a implementation class. It might have some problems.