3 function flatten($hash) {
4 if ( !is_array($hash) ) return $hash;
6 array_walk($hash, function($value, $key, &$to) {
7 array_push($to, $key, $value);
12 class FreesideSelfService {
15 function FreesideSelfService() {
16 $this->URL = 'http://' . variable_get('freeside_hostname','') . ':8080';
20 public function __call($name, $arguments) {
22 error_log("[FreesideSelfService] $name called, sending to ". $this->URL);
23 $request = xmlrpc_encode_request("FS.ClientAPI_XMLRPC.$name",
24 flatten($arguments[0])
26 $context = stream_context_create( array( 'http' => array(
28 'header' => "Content-Type: text/xml",
31 $file = file_get_contents($this->URL, false, $context);
32 $response = xmlrpc_decode($file);
33 if (xmlrpc_is_fault($response)) {
34 trigger_error("[FreesideSelfService] XML-RPC communication error: $response[faultString] ($response[faultCode])");
36 //error_log("[FreesideSelfService] $response");