X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/335f5e8f4be04e68fa76f64c722613efc6fb98fa..06c1548a92767365aa31a7af539475d535a33da3:/doc/xmlrpc.php diff --git a/doc/xmlrpc.php b/doc/xmlrpc.php new file mode 100644 index 00000000..6edce81f --- /dev/null +++ b/doc/xmlrpc.php @@ -0,0 +1,36 @@ + 'markup', 'encoding' => 'utf-8')); + $context = stream_context_create( + array('http' => array( + 'method' => 'POST', + 'header' => 'Content-Type: text/xml', + 'content' => $request))); + + $file = file_get_contents('http://localhost:8080/RPC2', false, $context); + $response = xmlrpc_decode($file); + + if (is_array($response) && xmlrpc_is_fault($response)) { + trigger_error("xmlrpc: {$response['faultString']} ({$response['faultCode']})"); + } + + return $response; +} + +// Usage samples + +print_r(__call('stargazer.info')); +$data = __call('stargazer.login', array('admin', '123456')); +if (isset($data['cookie'])) { + $cookie = $data['cookie']; + print_r($data); + print_r(__call('stargazer.get_tariffs', array($cookie))); + print_r(__call('stargazer.logout', array($data['cookie']))); +} + +?> +