PHP code example of thank-song / weather
1. Go to this page and download the library: Download thank-song/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/ */
thank-song / weather example snippets
use Weather;
//通过城市名称获取天气数据
$response = Weather::getByCity('Hangzhou');
//通过经纬度获取天气数据
//$response = Weather::getByCoords(30.2711, 120.1555);
//通过城市ID获取天气数据
//$response = Weather::getByCityId(1831806);
//通过邮编获取天气数据
//$response = Weather::getByZip(310000);
// $response 为一个Response对象,可用方法如下:
echo $response->getTemp();
echo $response->getMinTemp();
var_dump($response->getWeather());
var_dump($response->getMain());
//...
$weather = app('weather');
$response = $weather::getByCity('Hangzhou');
bash
php artisan vendor:publish --tag=config