#1  
Old 15th July 2014, 15:55
Xenocide Xenocide is offline
Member
 
Join Date: Sep 2010
Posts: 59
Thanks: 13
Thanked 10 Times in 9 Posts
Default Extending the API

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.
Reply With Quote
The Following User Says Thank You to Xenocide For This Useful Post:
robertoshulze2257 (25th July 2014)
Sponsored Links
  #2  
Old 15th July 2014, 16:22
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 37,015
Thanks: 840
Thanked 5,651 Times in 4,461 Posts
Default

Quote:
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.
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.

Quote:
Is that correct? Do I need to write a module and "install" it or can I add another file somewhere?
there is no new module needed, you can add your file e.g. in interface/lib/classes/ and then load it with $app->load('....');
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #3  
Old 15th July 2014, 16:40
Xenocide Xenocide is offline
Member
 
Join Date: Sep 2010
Posts: 59
Thanks: 13
Thanked 10 Times in 9 Posts
Default

Quote:
Originally Posted by till View Post
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.
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!
Reply With Quote
  #4  
Old 15th July 2014, 17:07
Xenocide Xenocide is offline
Member
 
Join Date: Sep 2010
Posts: 59
Thanks: 13
Thanked 10 Times in 9 Posts
Default

Quote:
Originally Posted by till View Post
there is no new module needed, you can add your file e.g. in interface/lib/classes/ and then load it with $app->load('....');
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 .
Reply With Quote
The Following User Says Thank You to Xenocide For This Useful Post:
Timmy Oblatus (5th October 2014)
  #5  
Old 15th July 2014, 17:17
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 37,015
Thanks: 840
Thanked 5,651 Times in 4,461 Posts
Default

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.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
The Following User Says Thank You to till For This Useful Post:
Timmy Oblatus (5th October 2014)
  #6  
Old 15th July 2014, 17:19
Xenocide Xenocide is offline
Member
 
Join Date: Sep 2010
Posts: 59
Thanks: 13
Thanked 10 Times in 9 Posts
 
Default

Quote:
Originally Posted by till View Post
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('....');
You the man. Can I marry you?

Thank you again.
Reply With Quote
The Following User Says Thank You to Xenocide For This Useful Post:
robertoshulze2257 (6th August 2014)
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
API system and docs VelusUniverse Developers' Forum 6 6th November 2013 17:59
Extending API Xenocide Developers' Forum 3 28th January 2013 19:31
API for third party modules SupuS General 1 6th October 2012 11:52
Folder Protection API snowfly General 4 9th January 2012 09:15
ISPConfig3 + API + BoxBilling class450dude Installation/Configuration 3 22nd August 2011 23:32


All times are GMT +2. The time now is 13:50.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.