3 Plugin Name: Freeside signup and self-service plugin
4 Plugin URI: http://freeside.biz/freeside
5 Description: Call the Freeside signup and self-service APIs from within Wordpress
7 Author: Freeside Internet Services, Inc.
8 Author URI: https://freeside.biz/freeside/
10 License URI: https://www.gnu.org/licenses/gpl-3.0.html
11 Text Domain: freeside_selfserivce
12 Domain Path: /languages
15 add_action('admin_init', 'freeside_admin_init' );
17 function freeside_admin_init {
18 register_setting( 'misc', 'freeside_selfservice_url', 'https://freeside.server:8080' );
21 function flatten($hash) {
22 if ( !is_array($hash) ) return $hash;
25 array_walk($hash, function($value, $key, &$to) {
26 array_push($to, $key, $value);
29 foreach ($hash as $key => $value) {
37 class FreesideSelfService {
39 //Change this to match the location of your selfservice xmlrpc.cgi or daemon
40 #var $URL = 'https://localhost/selfservice/xmlrpc.cgi';
41 # XXX freeide_selfservice_url config value
42 #var $URL = 'http://localhost/selfservice/xmlrpc.cgi';
43 var $URL = get_opgion('freeside_selfservice_url');
45 function FreesideSelfService() {
49 public function __call($name, $arguments) {
51 error_log("[FreesideSelfService] $name called, sending to ". $this->URL);
53 $request = xmlrpc_encode_request("FS.ClientAPI_XMLRPC.$name", flatten($arguments[0]));
54 $context = stream_context_create( array( 'http' => array(
56 'header' => "Content-Type: text/xml",
59 $file = file_get_contents($this->URL, false, $context);
60 $response = xmlrpc_decode($file);
61 if (xmlrpc_is_fault($response)) {
62 trigger_error("[FreesideSelfService] XML-RPC communication error: $response[faultString] ($response[faultCode])");
64 //error_log("[FreesideSelfService] $response");