epochblue / darksky-php
此包已被弃用且不再维护。没有推荐替代包。
DarkSky开发者API的PHP包装器
v1.0.0
2012-10-22 15:20 UTC
Requires
- php: >=5.2.0
This package is not auto-updated.
Last update: 2024-02-03 10:23:00 UTC
README
注意:此API包装器针对旧版本API,已被取代。此库不再维护。
一个用于与DarkSky API交互的简单PHP包装器。
要求
- PHP 5.2.0+
- DarkSky API密钥
安装
安装darksky-php
很简单,建议您使用Composer在项目中使用它。如果您是Composer的新手,请访问Composer网站以获取有关Composer是什么以及如何使用它的更多信息。一旦您的项目配置了Composer,要将darksky-php
包含在内,请将以下内容添加到您的composer.json
文件中
{ "require": { "epochblue/darksky-php": "dev-master" } }
添加完成后,从您的项目根目录运行php composer.phar update epochblue/darksky-php
,即可开始使用。
用法
darksky-php
包装器中的所有公共方法都返回关联数组。以下是此API包装器提供的所有公共方法的示例。有关返回值的更多详细信息,请参阅DarkSky API文档。
<?php // Creates an instance of the API wrapper. $darksky = new DarkSky('<YOUR API KEY HERE>'); // Returns a forecast for the next hour at a specific location $forecast = $darksky->getForecast(36.126617, -86.842756); // Returns a (slightly more brief) forecast for the next hour at a specific location $brief_forecast = $darksky->getBriefForecast(36.126617, -86.842756); // Returns forecasts for given locations at specific points in time // NOTE: the 'time' array key is optional. If it's not included, the current time will be used. $precipitation = $darksky->getPrecipitation( array( 'lat' => 36.126617, 'long' => -86.842756, 'time' => 1350612061 ), array( 'lat' => 36.126617, 'long' => -86.842756, 'time' => 1350600061 ), array( 'lat' => 36.126617, 'long' => -86.842756 ) ); // Returns a list of interesting storms going on at this moment $interesting = $darksky->getInterestingStorms();
作者
Bill Israel - https://github.com/epochblue - @epochblue
版权
版权所有 (c) 2012 Bill Israel。有关更多信息,请参阅包含的LICENSE
文件。