<?php
$data = array(
"serverUserName"=> "admin",
"controller"=>"submitUserCreation",
"firstName"=>"Usman",
"lastName"=>"Nasir",
"email"=>"[email protected] ",
"userName"=>"usmannasir",
"password"=> "cyberpanel",
"websitesLimit"=>5,
"selectedACL"=> "user"
);
$postdata = json_encode($data);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://cp.supernovadatacentre.com/cloudAPI/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>$postdata,
CURLOPT_HTTPHEADER => array(
'Authorization: Basic YWRtaW46cHp0eW5oZHVFa0kqNndzIw=='
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
Change the base64 token appropriately with what you see on phpmyadmin
I changed my password to reset the token. The token in that photo above is the correct one. I will change it back and test. WIll ss here the result.
My test is failing with domain and the key. Everytime. Not sure why.
Screenshot the whole request i want to see the url
Did you copy the token from phpmyadmin > loginSystemAdministrator > the row of the user you have enabled api access
make sure there are unecessary spaces at the end of the token on your postman variable
My cursor is at the end of the variable.
My friend you did not click on CTRL + S on the Collection Variable page after you changed the values. Save those changes and try again
That makes sense.
Now its stuck doing this.
The error recommends you use the desktop version.
Can you use postman for desktop or insomnia. It should work that is what am using
Yup give me just a second.
Is it because
cp.supernovadatacentre.com is essentially https:cp.supernovadatacentre.com:8090/?
So https{url}:8090 is going to https://cp.supernovadatacentre.com:8090:8090/?
I already highlighted that here
Yup that was it. Okay so now that it works in postman. how do I get it to work in the wordpress code? and inherit the variables entered by the user in the form?
I will reset my wordpress plugin to default so we have a fresh canvas.
Gotcha. I see. Okay so now I just replace the API token in this post?
<?php
$data = array(
"serverUserName"=> "admin",
"controller"=>"submitUserCreation",
"firstName"=>"Usman",
"lastName"=>"Nasir",
"email"=>"[email protected] ",
"userName"=>"usmannasir",
"password"=> "cyberpanel",
"websitesLimit"=>5,
"selectedACL"=> "user"
);
$postdata = json_encode($data);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://cp.supernovadatacentre.com/cloudAPI/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING =>…
That did not create a user in the panel.
You need to catch errors in your code that was just by the example you gave e.g.
...
CURLOPT_URL => 'https://cp.supernovadatacentre.com/cloudAPI/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FAILONERROR => true,
...
$response = curl_exec($curl);
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
}
curl_close($curl);
if (isset($error_msg)) {
// handle cURL error here
echo $error_msg
} else {
echo $response;
}
Okay Im handling curl errors now. Ill try to create the user again.