PHP code example of moay / opensensemap-api-php-client
1. Go to this page and download the library: Download moay/opensensemap-api-php-client library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
moay / opensensemap-api-php-client example snippets
$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')
}
$temperature = $senseBoxData->getValueByType(SensorValue::TYPE_TEMPERATURE);
echo 'Temperature: '.$temperature; // Output: Temperature: 12 °C
echo $temperature; // Output: 12 °C
$temperatureString = (string) $temperature // $temperatureString = '12 °C'
composer