ricbra / knmi-client
0.0.1
2016-11-29 20:48 UTC
Requires
- php: >=7.0
- php-http/client-implementation: ^1.0
- php-http/discovery: ^1.0
- php-http/httplug: ^1.0
- php-http/message-factory: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- guzzlehttp/psr7: ^1.0
- php-http/guzzle6-adapter: ^1.1
- php-http/message: ^1.0
- php-http/mock-client: ^0.3
- phpunit/phpunit: ^5.6
This package is not auto-updated.
Last update: 2024-09-14 19:20:21 UTC
README
KNMI客户端
此仓库包含一个用于KNMI 每小时 和 每日 端点的非常简单的PHP客户端。KNMI的响应相当不可用,此客户端返回一个格式良好的数组。虽然不是最好的,但比原始版本要好。
安装
由于我们使用php-http,您可以自由选择自己的HTTP客户端库。有关如何选择您最喜欢的客户端的更多信息,请参阅文档。
使用最新版Guzzle进行安装
$ composer require php-http/guzzle6-adapter ricbra/knmi-client guzzlehttp/psr7 php-http/message
如果您没有指定任何php-http适配器,Composer将报错
$ composer require ricbra/knmi-client
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- ricbra/knmi-client 1.0.x-dev requires php-http/client-implementation ^1.0 -> no matching package found.
- ricbra/knmi-client dev-master requires php-http/client-implementation ^1.0 -> no matching package found.
- Installation request for ricbra/knmi-client @dev -> satisfiable by ricbra/knmi-client[dev-master, 1.0.x-dev].
用法
<?php require 'vendor/autoload.php'; $guzzleAdapter = new \Http\Adapter\Guzzle6\Client(); $client = new \Ricbra\Knmi\Client($guzzleAdapter); $data = $client->getDaily( new \DateTime('2012-01-01'), new \DateTime('2012-01-03'), [ '240' ], [ 'PX', 'PN' ] ); $data = $response = $client->getHourly( new \DateTime('2016-01-01 12:00'), new \DateTime('2016-01-01 13:00'), ['240'], ['P'] );