wjzijderveld / youless-client
dev-master
2014-10-02 08:37 UTC
Requires
- beberlei/assert: ~2.0
- kriswallsmith/buzz: ~0.12
Requires (Dev)
- phpspec/phpspec: ~2.1@dev
This package is not auto-updated.
Last update: 2024-09-24 03:54:23 UTC
README
该库的目标是提供一个简单的API来访问Youless web服务。
安装
$ composer install
运行测试
$ ./vendor/bin/phpspec run
使用方法
使用Buzz\Browser实例和您Youless web服务可访问的URL实例化客户端。
$browser = new Buzz\Browser(); $client = new Wjzijderveld\Youless\Api\Client($browser, 'http://youless.yrl.here');
客户端有5种数据检索方法
// Request current usage $client->getRecentData(); // Wjzijderveld\Youless\Api\Response\Recent // Request data per day for a given month // (1 - 12, 1 = January, 12 = December) $client->getDataForMonth(1); // Wjzijderveld\Youless\Api\Response\History // Request data per hour for a given day in the last week // (0 - 6, 0 is today, 6 is 6 days ago) $client->getDataForDay(1); // Wjzijderveld\Youless\Api\Response\History // Request data per 10 minutes for the last 8 hours // (1 = last 8 hours, 2 = 8 till 16 hours ago, 3 = 16 - 32 hours ago) $client->getDataFor8Hours(1); // Wjzijderveld\Youless\Api\Response\History // Request data per minute for the last 30 minutes // (1 = last 30 minutes, 2 = 30 minutes till 60 minutes ago) $client->getDataFor30MInutes(1); // Wjzijderveld\Youless\Api\Response\History
Recent
对象提供当前使用情况和总使用情况的数据。
History
对象提供瓦特值,每个值与第一次测量的日期之间的秒数差。