Noob guide to api

Discussion in 'General' started by ginner159, Jul 23, 2013.

  1. ginner159

    ginner159 New Member

    Hello all,

    Im wanting to start using the api for ispconfig 3 but i have no idea what im doin with it. Is there anywhere you can point me to learn how to use it but for a complete noob to API's. I understand the concept of them just not how to use them.
    Even better would be cool if someone could share a basic add client script i could follow and adapt.

    Im hoping to be able to add clients, their, domain, email addr, databases, dns records ect all from one sign up page.

    Thanks in advance :D
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The api documentation and example scripts are in ther emote_client folder of the ispconfug tar.gz file.
  3. ginner159

    ginner159 New Member

    I've found those cheers.

    But how do I use them? Would I just copy and paste them into a php file and create a form to pass the data on to the scripts?
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Yes, thats one option to use them.
  5. ginner159

    ginner159 New Member

    Oh really that easy!? Ill try tonight after work and ask again if I get stuck

  6. ginner159

    ginner159 New Member

    Need a bit of help

    So i made a remote user, uploaded the client_add.php and soap_config from the templates went to and boom it added the client! which is great, but ... im now stuck with passing form data to the php script so that i can set the values required from a user input.

    I've attached my copy of the client_add.php file (in txt format as you can see just testing) which i'm using dreamweaver to develop hence the spry textboxes etc (anyone know a better way)

    Am i on the right track with what i've done? if so how would i pass the user inputs to the ispconfig array?

    Thanks again for the help

    Attached Files:

  7. ginner159

    ginner159 New Member

    Anybody?? Or can anyone link me to a really simple tutorial?

    [email protected] New Member

    Processing form input

    When you submit your form to client_add.php, your form variables will be in the form of $_POST['variable'] because you used
    . So in your parameters for the array, use those variables instead of the static values in your test script. I.e:

    $params = array(
    'company_name' => 'awesomecompany',
    'contact_name' => 'name' ...
    would be:

    $params = array(
    'company_name' => $_POST['company_name'],
    'contact_name' => $_POST['customer_name']...
    in your processing php file. So if adding the client worked with the test script and you got an "awesomecompany" client in ISPConfig, I would think you're on the right track. Just replace those static values with the $_POST variables from user input in the form.
    Last edited: Aug 8, 2013

    [email protected] New Member

    Yea, def the right track

    I tested the code from the documentation (that's in your file), and replaced all the 'values' in the array with my $_POST['variables'] from the form, and it worked perfectly. So you're def good to go if you just swap in those variables.

    Good luck!
  10. ginner159

    ginner159 New Member

    thanks for that! ill get coding when i get home! think i may submit a decent tutorial with what Ive gained from this.

    Thanks again
  11. ginner159

    ginner159 New Member


    think ive got a fun few weeks of learning php and php-mysql

    will add an updated version of the form shortly
  12. ginner159

    ginner159 New Member

    update to client api

    so i've been tinkering and come to a small snag. I've managed to get the page to add a client perfectly. I've now added the option for a subdomain so that clients get a website set up straight away to which they can add stuff too.

    The problem is tho when the subdomain is made it isnt assigning it to a client??
    The subdomain is made as a website so that they have there own space as outlined in the ispconfig manual ie

    updated script attached

    Attached Files:

  13. Trax

    Trax New Member

    Hi ginner159, did you ever get this to function without any issues? I've been looking for something like this for a while if you care to share what you have so far?

    Much appreciated :)
  14. ginner159

    ginner159 New Member

    I've got something that works but needs a little work on the style to match your site. It's just pure code. Also it needs some work on error correction such as min characters and checking email address etc. I just used dreamweaver to do it but it dosent work very well. Just replace with php error correction. I've not updated it for a while as I've been busy but will keep on with it so that everyone can have a style free form well documented and easy to use.

    Will update when I get home
  15. ginner159

    ginner159 New Member

    Update for every one

    Just letting you all know im still working onthis and will share once sorted. ive managed to get rid of the files dreamweaver created and am just adding in php error corrections so can be uploaded to anyones site.

    At present its just a simple client add script. Functions to add:

    • error correction
    • email user details to new client
    • login page
    • client details update page
    • documentation

    If something can be added to the list let me know :)
  16. Trax

    Trax New Member

    Cool, thanks for update :)
  17. ginner159

    ginner159 New Member

    Hit a small snag

    Ive got it all working great adding a client, adding a website and dns records but im stuck when it comes to only activating the client once the client has paid.

    I have the billing module installed and have the api's for it but would like it to turn the client active after the IPN request accepts that the bill has been paid.

    Id like it this way so that im not hosting for freeloaders trying to abuse my servers.
  18. till

    till Super Moderator Staff Member ISPConfig Developer

    The option to activate / deactivate a client is new in svn, it might be that changes in the api are required for them. Havent tested that yet. But you can activate the items like website or mailboxes trough the api.
  19. ginner159

    ginner159 New Member

    When was the last time the api was updated? would like to hope i've been building against the most recent version :/

    Would i be able to just add the api calls to the ipn.php file? I'm using the standard paypal one included in the module

    so i would do: php include of soap-config.php somewhere near the top then where it accepts the request use the api hooks to activate client??
  20. till

    till Super Moderator Staff Member ISPConfig Developer

    The api was updated 3 mnths ago and the api base library 21 days ago.

    The remote api is for external applications. For internal code and extensions, you would use the mysql datalogInsert and datalogUpdate and other mysql functions to query and manipulate the data in the database directly.

Share This Page