summaryrefslogtreecommitdiff
path: root/fs_selfservice/drupal/freeside.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'fs_selfservice/drupal/freeside.class.php')
-rw-r--r--fs_selfservice/drupal/freeside.class.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/fs_selfservice/drupal/freeside.class.php b/fs_selfservice/drupal/freeside.class.php
new file mode 100644
index 000000000..cf49a03d8
--- /dev/null
+++ b/fs_selfservice/drupal/freeside.class.php
@@ -0,0 +1,43 @@
+<?php
+
+function flatten($hash) {
+ if ( !is_array($hash) ) return $hash;
+ $flat = array();
+ array_walk($hash, function($value, $key, &$to) {
+ array_push($to, $key, $value);
+ }, &$flat);
+ return($flat);
+}
+
+class FreesideSelfService {
+
+ public $URL = '';
+ function FreesideSelfService() {
+ $this->URL = 'http://' . variable_get('freeside_hostname','') . ':8080';
+ $this;
+ }
+
+ public function __call($name, $arguments) {
+
+ error_log("[FreesideSelfService] $name called, sending to ". $this->URL);
+ $request = xmlrpc_encode_request("FS.ClientAPI_XMLRPC.$name",
+ flatten($arguments[0])
+ );
+ $context = stream_context_create( array( 'http' => array(
+ 'method' => "POST",
+ 'header' => "Content-Type: text/xml",
+ 'content' => $request
+ )));
+ $file = file_get_contents($this->URL, false, $context);
+ $response = xmlrpc_decode($file);
+ if (xmlrpc_is_fault($response)) {
+ trigger_error("[FreesideSelfService] XML-RPC communication error: $response[faultString] ($response[faultCode])");
+ } else {
+ //error_log("[FreesideSelfService] $response");
+ return $response;
+ }
+ }
+
+}
+
+?>