Skip to content

ServerAuth Web API

Flavius12 edited this page May 24, 2015 · 13 revisions

Table of Contents

Basic Tutorial

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));
?>

ServerAuth Web API Constants

SUCCESS

Description:
Success
Value:
1

ERR_OUTDATED_WEBAPI

Description:
Outdated ServerAuthWebAPI error
Value:
2

ERR_OUTDATED_PLUGIN

Description:
Outdated ServerAuth plugin error
Value:
3

ERR_MYSQL

Description:
MySQL error
Value:
4

ServerAuth Web API Functions

ServerAuth Web API construct:

function __construct($host, $port, $username, $password, $database, $table_prefix)

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
Description:
Initialize a new ServerAuth Web API instance

Get Status:

int getStatus()

Description:
Initialize a new ServerAuth Web API instance
Return:
int SUCCESS, ERR_OUTDATED_WEBAPI, ERR_OUTDATED_PLUGIN or ERR_MYSQL