洪流代码男孩/world-weather-online-laravel

此包已废弃且不再维护。未建议替代包。

允许在Laravel应用程序中轻松使用Weather Online API。目前仅支持高级API。

v0.10 2014-03-27 17:13 UTC

This package is not auto-updated.

Last update: 2022-05-23 14:42:22 UTC


README

此包用于与World Weather Online API交互。它是为Laravel 4开发的。给定一个位置,它将返回温度或完整的天气对象。

安装

  1. 安装Composer: https://getcomposer.org/doc/00-intro.md
  2. 编辑您的laravel项目中的composer.json文件,并在"require"部分添加:"floodedcodeboy/world-weather-online-laravel": "dev-master"。
  3. 运行"composer update"。
  4. 通过World Weather Online获取API密钥: http://developer.worldweatheronline.com/
  5. 编辑vendor/floodedcodeboy/world-weather-online-laravel/src/config中的config.php文件,并将API密钥放入其中
  6. 在app/config/app.php中的'providers'下添加Service提供者:Floodedcodeboy\WorldWeatherOnline\WorldWeatherOnlineServiceProvider

示例用法

在您的应用中创建对象,并调用适当的函数。

$WorldWeatherOnline = App::make('worldweatheronline');

$location = 'London, UK';
$temperature = $WorldWeatherOnline::current_temp($location);
$condition = $WorldWeatherOnline::current_conditions($location);

$location2 = '-33.8678500, 151.2073200';
$temperature = $WorldWeatherOnline::current_temp($location2);
$condition = $WorldWeatherOnline::current_conditions($location2);