guhelski/forecast-php

PHP中的简单Dark Sky API包装器

1.1.1 2016-09-26 04:35 UTC

This package is not auto-updated.

Last update: 2024-09-23 18:23:06 UTC


README

极其简单的 Forecast.io API v2 Dark Sky API包装器,使用PHP。

这允许您尽可能直接地从 Dark Sky API文档 转到代码。

遵循PSR规范且无任何依赖。不包括抽象。

安装

使用 Composer 简单快捷

composer require guhelski/forecast-php

使用方法

调用一个方法就这么简单。

<?php

use Forecast\Forecast;

$forecast = new Forecast('YOUR_API_KEY');
  
// Get the current forecast for a given latitude and longitude
var_dump($forecast->get('37.8267','-122.423'));
  
// Get the forecast at a given time
var_dump($forecast->get('37.8267','-122.423', '2013-05-06T12:00:00-0400'));
  
// Use some optional query parameters
var_dump($forecast->get(
    '37.8267',
    '-122.423',
    null,
    array(
        'units' => 'si',
        'exclude' => 'flags'
        )
    )
);

有关更多详细信息以及所有可用选项,请查看 官方文档