How to use Cyberpanel API in Wordpress?

No. CSRF issue is occuring becuase you are not generating the token properly. where is the code that generates the token?

I pulled the api key from the phpmyadmin. It needs to be where? Also if I get it to work in postman, how do I port it to the woocommerce plugin?

He said we could use the token from phpmyadmin > search admin > loginSystemAdministrator.

Im looking for the place to put the code to run it to create a token in postman. Do I run a test? Do I throw that code in my woocomerse plugin? Im a bit confused.

Good just tested it works with that.

Generating a base64 token for yourself will work like this for php:

<?php
$admin_user = 'admin';
$admin_password='somecomplexpassword';
$str = $admin_user. ":". $admin_password;
echo base64_encode($str);
?>

Okay got it. So im getting this when I run a test.

<?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.

image
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.