PHP code example of oscarmx / laravel-weather
1. Go to this page and download the library: Download oscarmx/laravel-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/ */
oscarmx / laravel-weather example snippets
use Oscarmx\LaravelWeather\Weather;
$key = '你的高德开放平台API Key';
$weather = new Weather($key);
##获取实时天气
$response = $weather->getWeather('深圳');
##获取近期天气预报
$response = $weather->getWeather('深圳', 'all');
##第三个参数为返回值类型,可选 json 与 xml,默认 json
$response = $weather->getWeather('深圳', 'all', 'xml');