Virtualmin API not working with PHP Script

I am using the code below to make use of the Virtualmin API using PHP,


<?php $result = shell_exec(http://www.php.net/shell_exec)("wget -O - --quiet --http-user=root --http-passwd=pass --no-check-certificate 'https://localhost:10000/virtual-server/remote.cgi?program=list-domains'"); echo $result; ?>

Source: https://www.virtualmin.com/documentation/developer/http

But it’s now working as expected it is always giving error “You are already hosting this domain” and status “failed”

But the same command is working fine if I am using it from shell or CLI directly.

Please help me with this, I also request if someone has the API ready in PHP if he or she can provide.

Thanks

I don’t know enough about PHP to say, but I know that XML-RPC in Webmin stopped working for one user because their app was using a non-Unicode encoding. It may be worth checking/trying.

Here’s the ticket about it:

I’ll try to test and update the documentation soon, if it needs a change.

1 Like

Well, as I was developing API program I noticed that these commands are actually working but have some issue, like if I am creating a new virtual server then it’s actually creating the server, no issue on that but after creating, it is just refreshing the same page and hence it’s repeating the same code and this time it’s throwing error that the domain already exist, since it’s already been created on the last execution.

I can ensure this because, my script structure goes like, first It will check if that domain exist in the server or not, if it does not exist then it will proceed to create new virtual server with that domain else it will throw the error returned by the API or command.

Hence, it’s first checking for my new domain then it’s creating the virtual server and then reloading the page, now this time since the domain is already there, it’s just throwing error returned, which is actually true.

Can this be resolved :frowning: