summaryrefslogtreecommitdiff
path: root/fs_selfservice/fri/includes/freeside.class.php
blob: a4413984e677d7b2ebc4748b3c4d1d4323ae3f95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
class FreesideSelfService  {

    //Change this to match the location of your selfservice xmlrpc.cgi or daemon
    //var $URL = 'https://www.example.com/selfservice/xmlrpc.cgi';
    var $URL = 'http://localhost/selfservice/xmlrpc.cgi';

    function FreesideSelfService() {
      $this;
    }

    public function __call($name, $arguments) {

        error_log("[FreesideSelfService] $name called, sending to ". $this->URL);

        $request = xmlrpc_encode_request("FS.SelfService.XMLRPC.$name", $arguments);
        $context = stream_context_create( array( 'http' => array(
            'method' => "POST",
            'header' => "Content-Type: text/xml",
            'content' => $request
        )));
        $file = file_get_contents($this->URL, false, $context);
        if (!$file) {
            trigger_error("[FreesideSelfService] XML-RPC communication error: file_get_contents did not return");
        } else {
            $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;
            }
        }
    }

}

?>