Community
OpenEnergyMonitor

Community

Accessing latest data via PHP

Tags: #<Tag:0x00007f6e1092add0> #<Tag:0x00007f6e1092ab50> #<Tag:0x00007f6e1092a998>

I’m trying to create a PHP script to obtain and send the latest PHPfina data and send it via CURL to a separate server. I’ve found PHPfina.php in pi/usefulscripts/convertdata/Lib and see there is a ‘lastvalue’ function - but I’m having trouble getting it to work. My code is:

require_once("./pi/usefulscripts/convertdata/Lib/PHPFina.php");

$finaFeed = 1;
$PHPFina = new PHPFina;
$lastData = $PHPFina->lastvalue($finaFeed);
$timestamp = $lastData['time'];
$data = $lastData['value'];

…but I’m getting:

PHP Warning: Missing argument 1 for PHPFina::__construct(), called in /home/send_data_to_blockchain.php on line 15 and defined in /home/pi/usefulscripts/convertdata/Lib/PHPFina.php on line 23
PHP Fatal error: Class ‘EmonLogger’ not found in /home/pi/usefulscripts/convertdata/Lib/PHPFina.php on line 27

Am I missing another include? Or is there a better way of accessing the PHPfina data?

Chris.

Actually it looks like its easier to just use the emoncms API!

Chris.