How PHP works with Vestacp through web api?
-
- Posts: 7
- Joined: Fri Nov 20, 2015 8:00 am
How PHP works with Vestacp through web api?
Hey guys! Looking forward to your help. Thank you!
I installed Vestacp, I have an idea to turn it into DDNS domain with subdomains.
I'm having a problem is how to create sub domains with A record IP account with PHP.
Please guide me!
I am using this code, but it is not working.
I installed Vestacp, I have an idea to turn it into DDNS domain with subdomains.
I'm having a problem is how to create sub domains with A record IP account with PHP.
Please guide me!
I am using this code, but it is not working.
Code: Select all
<?php
// Server credentials
$vst_hostname = 'abc.com';
$vst_username = 'admin';
$vst_password = 'password';
$vst_returncode = 'yes';
$vst_command = 'v-add-dns-record';
// New Domain
$username = 'admin';
$domain = 'abc.com';
$record = 'test.abc.com'; // SUBDOMAIN.YOUR.DOMAIN
$type = 'A';$value = '8.8.8.8';
// Prepare POST query
$postvars = array( 'user' => $vst_username,
'password' => $vst_password,
'returncode' => $vst_returncode,
'cmd' => $vst_command,
'arg1' => $username,
'arg2' => $domain,
'arg3' => $record,
'arg4' => $type,
'arg5' => $value
);
$postdata = http_build_query($postvars);
// Send POST query via cURL
$postdata = http_build_query($postvars);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://'.$vst_hostname.':8083/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl);
// Check result
if($answer == 0) {
echo "DNS ZONE " . $record ." has been successfully created and points to " . $value . "\n";
} else {
echo "Could not create " . $record . "\nQuery returned error code: " .$answer. "\n";
}
?>
Re: How PHP works with Vestacp through web api?
Can you post the output of this code? So I can take a look on what's happen.
-
- Posts: 7
- Joined: Fri Nov 20, 2015 8:00 am
Re: How PHP works with Vestacp through web api?
I coppy it on vestacp.com/doc api but it is not working . you need the output : "user=admin&password=password&returncode=yes&cmd=v-add-dns-record&arg1=admin&arg2=abc.com&arg3=test.abc.com&arg4=A&arg5=8.8.8.8"
I put this php file in the folder public_html
I put this php file in the folder public_html
-
- Posts: 7
- Joined: Fri Nov 20, 2015 8:00 am
Re: How PHP works with Vestacp through web api?
can anyone help me?
-
- Collaborator
- Posts: 783
- Joined: Mon May 11, 2015 8:43 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: How PHP works with Vestacp through web api?
can you try with:
Code: Select all
$username = 'admin';
$domain = 'abc.com';
$record = 'test';
$type = 'A';
$value = '8.8.8.8';
-
- Posts: 7
- Joined: Fri Nov 20, 2015 8:00 am
Re: How PHP works with Vestacp through web api?
Thanks you! it's work.
Can you help me again? How to set dns forward for 8.8.8.8 & 8.8.4.4
Can you help me again? How to set dns forward for 8.8.8.8 & 8.8.4.4
-
- Collaborator
- Posts: 783
- Joined: Mon May 11, 2015 8:43 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: How PHP works with Vestacp through web api?
What do you want to achieve? You can change your DNS settings in /etc/resolv.conf. But that might not be what you're looking for?truytim123 wrote:Thank you! it's work.
Can you help me again? How to set DNS forward for 8.8.8.8 & 8.8.4.4