Home >Backend Development >PHP Tutorial >Weather query citycode query interface, also available in sae

Weather query citycode query interface, also available in sae

WBOY
WBOYOriginal
2016-07-25 08:49:471166browse
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';
  1.  $ cityCode = file_get_contents($url);
  2. if($cityCode == '' || $cityCode == NULL){
  3. return NULL;
  4. }else{
  5. return $cityCode;
  6. }
  7. }
  8. Copy code
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn