hi,
i tried above steps.
but it doesn't seem to be working.
and regarding error: I get empty response, so not sure where exactly the error is.
Code used:
Code: Select all
$vst_hostname = env('VESTA_HOSTNAME');
$vst_username = env('VESTA_USERNAME');
$vst_password = env('VESTA_PASSWORD');
$vst_returncode = 'yes';
$vst_command = 'v-add-domain';
$username = env('VESTA_SUBUSER');
$domain = $request->name;
$postvars = array(
'user' => $vst_username,
'password' => $vst_password,
'returncode' => $vst_returncode,
'cmd' => $vst_command,
'arg1' => $username,
'arg2' => $domain
);
$postdata = http_build_query($postvars);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $vst_hostname . ':8058/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);
if($answer == 0) {
return "Domain has been successfuly created\n";
} else {
return "Query returned error code: " .$answer. "\n";
}
Already added API white list ips based on above post.
also changed url endpoint with secret url like
curl_setopt($curl, CURLOPT_URL, 'https://' . $vst_hostname . ':8058/api/?secret');
still no luck. anything needs to be done to get it work?