moay/opensensemap-api-php-client
Composer 安装命令:
composer require moay/opensensemap-api-php-client
包简介
A client for retrieving sensor data from a senseBox from the opensensemap api
README 文档
README
opensensemap-api-php-client
A lightweight client for retrieving sensor data from a senseBox from the opensensemap api.
This is not an official project from the senseBox team.
Setup
Install via composer:
composer require moay/opensensemap-api-php-client
Usage
Take a look at the implementation example in the directory example.
$client = OpensensemapApiClientFactory::create(); // Change senseBox id $senseBoxData = $client->getSenseBoxData('someSenseBoxId'); foreach ($senseBoxData as $sensorValue) { // $sensorValue->getValueType() // $sensorValue->getValue() // $sensorValue->getUnit() // $sensorValue->getSensorType() // $sensorValue->getMeasurementTime()->format('Y-m-d H:i:s') }
You don't have to iterate over all values, just use this handy function:
$temperature = $senseBoxData->getValueByType(SensorValue::TYPE_TEMPERATURE);
Outputting values can be done directly by casting the values to strings:
echo 'Temperature: '.$temperature; // Output: Temperature: 12 °C echo $temperature; // Output: 12 °C $temperatureString = (string) $temperature // $temperatureString = '12 °C'
Features
The client gives you the latest data for a specific senseBox from the OpenSenseMap Api.
As there was no need for further features, none have been implemented. This could easily be done, though. Feel free to submit a PR.
License
The client is published under the MIT license.
senseBox and all related contents, visuals and brands are published under CC licenses or other public domain licenses. Make sure to check out the project.
统计信息
- 总下载量: 33
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-01
