1. Go to this page and download the library: Download mosagx/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/ */
mosagx / weather example snippets
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Mosagx\Weather\Weather;
class Controller extends BaseController
{
public function test(Request $request, Weather $weather)
{
// live weather data
$live_data = $weather->getLiveWeather($request->input('city', '北京'));
// forecasts weather data
$forecasts_data = $weather->getForecastsWeather($request->input('city', '北京'));
}
}
osagx\Weather\Weather;
$key = 'xx'; // your amap weather application key
$weather = new Weather($key);
// live weather data
$live_data = $weather->getLiveWeather('北京');
// forecasts weather data
$forecasts_data = $weather->getForecastsWeather('北京');