View Full Version : API for Dummies
tlchost
06-18-2007, 03:36 PM
As loath as I am to admit it, I must have a mental block about the API syntax. I see many posts with things like:
CMD_API_DATABASES
no parameters:
lists the databases with encoded url: list[]=username_db1&list[]=username_db2
action=create
name=dbname (username_ will be added)
user=user (username_ will be added)
passwd=pass
passwd2=pass
action=delete
select0=username_dbname
(select1=username_db2, etc...)
I think I would call this by mydomain.com:2222/CMD_API_DATABASES
But then what?
Is there a tutorial for the API stuff? If not, can someone point me to an API call that shows how I pass the information above and one that uses a webform for input?
Thanks...it's bad enough not understanding what everyoine else does, it's even worse to admit it in public.:confused:
floyd
06-19-2007, 02:24 PM
http://www.directadmin.com/api.html
tlchost
06-19-2007, 04:15 PM
http://www.directadmin.com/api.html
Thanks...I took a quick look and it's still over my head....
For instance
Create Admin:
Function To create a new admin account
Command CMD_ACCOUNT_ADMIN
Method GET or POST
Success Returns Text
Failure Returns Text
Form Values:
Name Value
action create
username The Admin's username. 4-8 characters, alphanumeric
email A valid email address
passwd The admins password. 5+ characters, ascii
passwd2 Password double check. 5+ characters, ascii
notify yes or no. If yes, an email will be sent to email
Are the variable names and values enterted into the browser, ala some cgi scripts ?Name=DoDo,Action=create
Can it be done via a webpage form?
Please forgive the simple questions...but this stuff is obviously in one of my personal blind spots
floyd
06-19-2007, 06:29 PM
I think you will understand the api once you figure out how to write a http GET or POST. These are done differently depending on what program you are using.
Here is an example of how a user would be created
htp://username:password@server_ip:2222/CMD_API_ACCOUNT_USER?action=create&package=package_name&add=Submit¬ify=no&username=new_username&email=new_user_email&passwd=new_user_password&passwd2=new_user_password&ip=server_ip
This would create a new user using the GET command. How you implement this depends on what programming language you are using. It can be done via a GET or a POST.
This would not work in a browser because you cannot pass the username and password in the url. But a script can. And even if the script cannot you would then just create a http post instead.
Tell us what language you would prefer to write in and one of us can show you an example if you need it.
l0rdphi1
06-20-2007, 01:58 AM
Hi,
Just as a general note, there are some API usage examples in old posts on the Scripting / API forum (http://www.directadmin.com/forum/forumdisplay.php?f=41) that may be of some use.
I also have some basic PHP API examples here: http://kade.nu/da/httpsocket/examples/
Good luck!
Phil
Powered by vBulletin™ Version 4.0.4 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.