I use few specific globalvars in Domotiga.
I created my own web page to read Domotiga status based on Domotiga PHP page. Working fine.
First I use this code (extract from functions.php):
Code: Select all
function do_xmlrpc($request) {
global $rpc_connect;
global $use_curl;
if ( $use_curl == "yes" ) {
$ch = curl_init($rpc_connect);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$request");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$context = curl_exec($ch);
if ( curl_error($ch) == "" ) {
curl_close($ch);
return xmlrpc_decode($context,"UTF-8");
} else {
curl_close($ch);
die ("<h2>Cannot connect to the DomotiGa server!</h2>");
}
} else {
$context = stream_context_create(array('http' => array('method' => "POST",'header' =>"Content-Type: text/xml",'content$
if ($file = @file_get_contents($rpc_connect, false, $context)) {
$file=str_replace("i8","double",$file);
return xmlrpc_decode($file, "UTF-8");
} else {
die ("<h2>Cannot connect to the DomotiGa server!</h2>");
}
}
}
Based on this, I created a function to get Globalvar list :
Code: Select all
// Get Globalvar list
function get_globalvar_list() {
$request = xmlrpc_encode_request("globalvar.list",null);
$response = do_xmlrpc($request);
if (xmlrpc_is_fault($response)) {
trigger_error("xmlrpc: $response[faultString] ($response[faultCode])");
} else {
$index=0;
foreach($response AS $item) {
list($retarr[$index]['globalvarname'], $retarr[$index]['globalvarvalue']) = explode (';;', $item);
$index++;
}
if (isset($retarr)) {
return $retarr;
} else {
return FALSE;
}
}
}
I used print_r($response) to see the array and there is no value... only a globalvar name. So I think I have to use globalvar.get to read the value.. isn't it ?
Question :
How to get/read a globalvar in PHP ?
I tried to use Globalvar.get but with no real success !
I found this page http://www.domotiga.nl/projects/domotig ... igaversion but I don't understand how to use this globalvar.get method...
Could you help me to understand how to use this method ?
Thanks a lot in advance for your support.
Regards.