*/
header('Content-type: text/plain');
// where am i
$root = '/home/bc/therm';
// ip address of radiotherm
$radiotherm = '10.20.30.40';
// your Pachube read/write api key
$pachube_api_key = 'put a key here';
// your pachube put url
$puturl = 'http://api.pachube.com/v2/feeds/XXXXX/datastreams/';
require_once $root . '/Tstat/Autoloader.php';
require_once $root . '/Pachube/pachube_functions.php';
Tstat_Autoloader::register();
$request = new Tstat_Client($radiotherm);
$datas = json_decode($request->info());
$pachube = new Pachube($pachube_api_key);
$environ = $pachube->environment('15729');
print "Environment:\n\n";
print_r($environ);
print "\n\n";
print "temp:\n\n";
print_r($datas->temp);
print "\n\n";
print "theat:\n\n";
print_r($datas->t_heat);
$response = $pachube->updatePachube($puturl . 'temp.csv', $datas->temp);
print "\n\n";
print "temp put response:\n\n";
print_r($response);
$response = $pachube->updatePachube($puturl . 'theat.csv', $datas->t_heat);
print "\n\n";
Exemple #2
0
<?php

require_once 'pachube_functions.php';
# *****************************************************************
#
# Create a Pachube object and pass your API key
#
# *****************************************************************
$api_key = "mFgy2cgsyv4GKhw4G4EzNcpgpfhQJkg4JvCrNpOskwo";
$pachube = new Pachube($api_key);
// note that you must own the feed listed below in order to update it!
$url = "http://www.pachube.com/api/25375.csv";
$data = $_GET["value"];
$myFile = "phptest.txt";
$fh = fopen($myFile, 'w') or die("0");
fwrite($fh, $data);
fclose($fh);
//echo "1";
// this next line makes the actual update attempt and returns a status code
$update_status = $pachube->updatePachube($url, $data);
echo "1";
//$pachube->debugStatusCode($update_status);
<?php

$datastream0 = $_POST["datastream0"];
$datastream1 = $_POST["datastream1"];
$datastream2 = $_POST["datastream2"];
$datastream3 = $_POST["datastream3"];
require_once 'pachube_functions.php';
$api_key = "your_api_key_here";
$feed_id = "your_feed_id_here";
$data = "0,{$datastream0}\n1,{$datastream1}\n2,{$datastream2}\n3,{$datastream3}";
$pachube = new Pachube($api_key);
$url = "http://api.pachube.com/v2/feeds/" . $feed_id . ".csv";
$update_status = $pachube->updatePachube($url, $data);
$pachube->debugStatusCode($update_status);
//