Esempio n. 1
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);
// 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";
print "theat put response:\n\n";
print_r($response);