Create server API

8 posts / 0 new
Last post
#1 Wed, 06/17/2009 - 04:12
mike.newgate

Create server API

Unfortunately not all the documentation is online. Therefore I have some trouble with the API. The only thing I want to do is creating a new virtual server with a certain pre-configured package with help of the API.

Can someone give an example? I would be very grateful.

Thanks in advance.

Wed, 06/17/2009 - 04:24
Joe
Joe's picture

Sorry for the inconvenience, Mike. API docs are coming back online tomorrow sometime.

But, note that all API docs are available in the product itself, as well (that's where we generate the online version from).

virtualmin --help

Lists all available commands.

And:

virtualmin create-domain --help

Will get you all the options for the create-domain command.

The remote version is identical, but you wrap up the options differently:

https://user:pass@domain.tld:10000/virtual-server/remote.cgi?program=cre...

If you just request remote.cgi with no query string it'll serve up a help text.

It's all pretty discoverable if you know where to look. (But without docs, I know it's not obvious where to look!)

--

Check out the forum guidelines!

Wed, 06/17/2009 - 14:04 (Reply to #2)
mike.newgate

Unfortunately I am still struggling with the API. This is what I have got so far:

$result = shell_exec("wget -O - --quiet --http-user=root --http-passwd=pass --no-check-certificate https://www.domain.tld:10000/virtual-server/remote.cgi?program=create-do...'");

Do I attached too little variables or is the problem something else?

Thanks in advance.

Wed, 06/17/2009 - 15:11 (Reply to #3)
Joe
Joe's picture

What errors are you getting?

--

Check out the forum guidelines!

Wed, 06/17/2009 - 15:20 (Reply to #4)
mike.newgate

None :-S

Wed, 06/17/2009 - 15:52 (Reply to #5)
Joe
Joe's picture

If you try it from the command line with the exact same options (running as root), do you get anything sensible?

--

Check out the forum guidelines!

Thu, 06/18/2009 - 03:21 (Reply to #6)
mike.newgate

I did not thought of that. Thanks :-)

Now I have something that works in the command-line, but I have no idea how I can use this in PHP. The command-line is: virtualmin create-domain --domain test.nl --pass 123 --default-features --plan "Klein"

And what I have tried in PHP is: $result = shell_exec("wget -O - --quiet --http-user=root --http-passwd=pass --no-check-certificate https://www.domain.tld:10000/virtual-server/remote.cgi?program=create-do...'");

Can somebody please help me. Thanks in advance!

Thu, 06/18/2009 - 03:31 (Reply to #7)
Joe
Joe's picture

So, take it another step forward in debugging...try running the wget command (without --quiet) from the command line. It seems like any errors are disappearing somewhere, and I don't know enough about PHP to tell you how to troubleshoot.

e.g.:


wget -O - --http-user=root --http-passwd=pass --no-check-certificate https://www.domain.tld:10000/virtual-server/remote.cgi?program=create-domain\&domain=test.nl\&pass=123\&default-features\&plan=Small

--

Check out the forum guidelines!

Topic locked