The first version is online: https://github.com/NiLSPACE/Login/tree/networkapi
By default the API is disabled. To enable go to you configuration file and change/add the NetworkAPI.Enabled to true. (Like this, but then Enabled = true
You'll have to come up with some sort of client secret that is at least 10 characters long to prevent misuse of the API. You can also change the port of the API if you want.
To call the API you send JSON to it. The JSON looks like this:
In PHP it looks somewhat like this:
The API also returns JSON which looks like this:
It only returns anything if everything was okay though. I still have to make it return something if something went wrong.
By default the API is disabled. To enable go to you configuration file and change/add the NetworkAPI.Enabled to true. (Like this, but then Enabled = true
You'll have to come up with some sort of client secret that is at least 10 characters long to prevent misuse of the API. You can also change the port of the API if you want.
To call the API you send JSON to it. The JSON looks like this:
Code:
{
action: 'APIAction', // Currently only RegisterUser is available.
playername: 'myplayername', // The name of the player to register
password: 'MyPassword', // The password that you want the user to have
}
In PHP it looks somewhat like this:
PHP Code:
function JsonRequest($url, $secret, $data) {
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: ' . $secret,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($data)
]);
$response = curl_exec($ch);
return $response;
}
JsonRequest("localhost:8888", "VerySecretPassword", [
'action' => 'RegisterUser',
'playername' => 'TestUser',
'password' => 'password'
]);
The API also returns JSON which looks like this:
Code:
{
"msg" : "The user is already registered",
"result" : "failed"
}