-
-
Notifications
You must be signed in to change notification settings - Fork 39
ServerAuth Web API
In this tutorial you will check if a ServerAuth account exists
1. Create example.php file in your Web Server directory
2. Add ServerAuthWebAPI.php file in the same directory
3. Now add this code in example.php
<?php
//Include ServerAuth Web API
include 'ServerAuthWebAPI.php';
//Player to check
$player = "Steve";
//Initialize a ServerAuthWebAPI instance (put your ServerAuth MySQL data)
$api = new ServerAuthWebAPI("host", 3306, "username", "password", "serverauth", "srvauth_");
var_dump($api->isPlayerRegistered($player));
?>
Description:
Success
Value:
1
Description:
Outdated ServerAuthWebAPI error
Value:
2
Description:
Outdated ServerAuth plugin error
Value:
3
Description:
MySQL error
Value:
4
function __construct($host, $port, $username, $password, $database, $table_prefix)
Description:
Initialize a new ServerAuth Web API instance
Parameters:
$host MySQL database host
$port MySQL database port (default 3306)
$username MySQL database username
$password MySQL database password
$database MySQL ServerAuth database
$table_prefix ServerAuth MySQL database table prefix
int getStatus()
Description:
Initialize a new ServerAuth Web API instance.
Return:
SUCCESS, ERR_OUTDATED_WEBAPI, ERR_OUTDATED_PLUGIN or ERR_MYSQL
string|int getVersion()
Description:
Get ServerAuth plugin version.
Return:
The current version string on SUCCESS, otherwise the current status
string|int getAPIVersion()
Description:
Get ServerAuth plugin version.
Return:
The current API version string on SUCCESS, otherwise the current status
string getWebAPIVersion()
Description:
Get ServerAuthWebAPI version
Return:
The current ServerAuthWebAPI version string.
string getPasswordHash()
Description:
Get ServerAuth Password Hash.
Return:
string
string getHost()
Description:
Get MySQL host.
Return:
string
int getPort()
Description:
Get MySQL port.
Return:
int
string getUsername()
Description:
Get MySQL username.
Return:
string
string getPassword()
Description:
Get MySQL password.
Return:
string
string getDatabaseName()
Description:
Get MySQL ServerAuth database name.
Return:
string
string getTablePrefix()
Description:
Get MySQL ServerAuth table prefix
Return:
string
mysqli|boolean getDatabase()
Description:
Get ServerAuth MySQLi instance.
Return:
mysqli on success
false on MySQL connection failure
boolean|int isPlayerRegistered($player)
Description:
Check if a player is registered to ServerAuth.
Parameters:
$player The player name
Return:
true or false on SUCCESS, otherwise the current status
array|int getPlayerData($player)
Description:
Get player data.
Parameters:
$player The player name
Return:
The array of player data on SUCCESS, otherwise the current status
int|boolean registerPlayer($player, $password, $ip, $firstlogin, $lastlogin)
Description:
Register a player to ServerAuth.
Parameters:
$player The player name
$password The player password
$ip The player IP
$firstlogin (UNIX timestamp) The player first login
$lastlogin (UNIX timestamp) The player last login
Return:
true on SUCCESS or false if the player is already registered, otherwise the current status
int|boolean unregisterPlayer($player)
Description:
Unregister a player from ServerAuth.
Parameters:
$player The player name
Return:
true on SUCCESS or false if the player is not registered, otherwise the current status
int|boolean changePlayerPassword($player, $new_password)
Description:
Change player password.
Parameters:
$player The player name
$new_password The new password
Return:
true on SUCCESS or false if the player is not registered, otherwise the current status
ServerAuth
ServerAuth Web API
ServerAuth Account Manager