Weather query citycode query interface will be used when using the National Weather Service weather forecast, you know.
function cityCode($cityName){ $url = 'http://someapi.sinaapp.com/citycode/?city='.urlencode($cityName).'&encode=utf-8';- $ cityCode = file_get_contents($url);
- if($cityCode == '' || $cityCode == NULL){
- return NULL;
- }else{
- return $cityCode;
- }
- }
-
-
- Copy code
|