PHP code example of sunsgne / weather

1. Go to this page and download the library: Download sunsgne/weather library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sunsgne / weather example snippets


$clientIp = $request->getRealIp();
sunsgne\Weather::getClientCityByIp($clientIp);

array(7) {     
  ["status"]=> 
  string(1) "1"
  ["info"]=>   
  string(2) "OK"
  ["infocode"]=>
  string(5) "10000"
  ["province"]=>
  string(9) "重庆市"
  ["city"]=>
  string(9) "重庆市"
  ["adcode"]=>
  string(6) "500000"
  ["rectangle"]=>
  string(46) "106.2832832,29.36962828;106.8138242,29.7401968"
}


$clientIp = $request->getRealIp();
sunsgne\Weather::liveWeather($clientIp);

$clientIp = $request->getRealIp();
sunsgne\Weather::forecastsWeather($clientIp);