PHP code example of tjzen / weather
1. Go to this page and download the library: Download tjzen/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/ */
tjzen / weather example snippets shell
$response = $weather->getWeather('天津');
shell
<response>
<status>1</status>
<count>1</count>
<info>OK</info>
<infocode>10000</infocode>
<forecasts type="list">
<forecast>
<city>天津市</city>
<adcode>120000</adcode>
<province>天津</province>
<reporttime>2018-11-14 11:00:00</reporttime>
<casts type="list">
<cast>
<date>2018-11-14</date>
<week>3</week>
<dayweather>霾</dayweather>
<nightweather>雾</nightweather>
<daytemp>15</daytemp>
<nighttemp>8</nighttemp>
<daywind>西南</daywind>
<nightwind>西南</nightwind>
<daypower>≤3</daypower>
<nightpower>≤3</nightpower>
</cast>
<cast>
<date>2018-11-15</date>
<week>4</week>
<dayweather>小雨</dayweather>
<nightweather>雨夹雪</nightweather>
<daytemp>11</daytemp>
<nighttemp>2</nighttemp>
<daywind>东北</daywind>
<nightwind>北</nightwind>
<daypower>5</daypower>
<nightpower>4</nightpower>
</cast>
...
</casts>
</forecast>
</forecasts>
</response>
shell
.
.
.
public function edit(Weather $weather)
{
$response = $weather->getWeather('深圳');
}
.
.
.
shell
.
.
.
public function edit()
{
$response = app('weather')->getWeather('深圳');
}
.
.
.