Hi again! I'd like to add some more custom functions to the API for our particular setup. Prehaps i'd release them if there's any interest. What's the best way to go about doing this so that it will not get over written if there's any updates? I assume I need to make a new file (is there a directory which gets included automatically for additions like this?) and then extend the "remoting" class to add my new functions. Is that correct? Do I need to write a module and "install" it or can I add another file somewhere? Many thanks in advance.
Thats correct for the current releases (3.0.5.4). In the next major version this will change to make it easier to have custom functions. In ISPConfig 3.1 (the git master branch) you have a interface/lib/classes/remote.d/ directory were you can simply drop your custom class and it gets included automaticalyl in the api. The api in 3-1 is also available as REST api beside the current SOAP api. there is no new module needed, you can add your file e.g. in interface/lib/classes/ and then load it with $app->load('....');
That sounds fantastic. I can't wait! Thank you for another prompt, in depth and helpful reply till. I really appreciate it! Now I know where to look i'll have a crack and see how I get on. Thanks again!
Hi till, Sorry to be back so soon. I was wondering if you could elaborate on this a bit more. Where can I put the $app->load() line so that it won't be over written in future updates? Also if I were to extend the remoting class, eg: remoting.inc.php Code: class remoting { ... } custom_remoting.inc.php Code: class custom_remoting extends remoting { ... } Then wherever the Code: $whatever = new remoting(); bit is, it would need to be changed? I may have to put this off until 3.1 .
1) Create a new file in the interface/web/remote/ folder, e.g. custom.php with this content: Code: <?php require_once '../../lib/config.inc.php'; $conf['start_session'] = false; require_once '../../lib/app.inc.php'; if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.'); $app->load('remoting'); $app->load('custom_remoting'); $app->uses('remoting_lib'); $server = new SoapServer(null, array('uri' => $_SERVER['REQUEST_URI'])); $server->setClass('custom_remoting'); $server->handle(); ?> 2) in interface/lib/classes/ you add a file custom_remoting.inc.php which contains your custom remoteing class that extends the "normal" remoting class. 3) from your external scripts, you use remote/custom.php as remote endpoint for the soap calls.