JSONAPI: PHP SDK


JSONAPI\JSONAPI
JSONAPI.php at line 14

Class JSONAPI

JSONAPI

public class JSONAPI

A PHP class for access Minecraft servers that have Bukkit with the JSONAPI plugin installed.

This class handles everything from key creation to URL creation to actually returning the decoded JSON as an associative array.

Author:
Alec Gorge
Version:
Alpha 5
See Also:
http://github.com/alecgorge/JSONAPI
Since:
Alpha 5

Method Summary
void

__construct(mixed host, mixed port, mixed uname, mixed pword, mixed salt)

Creates a new JSONAPI instance.

array

call(string method, array args)

Calls the single given JSONAPI API method with the given args.

array

callMultiple(array methods, array args)

Calls the given JSONAPI API methods with the given args.

string

createKey(string method)

Generates the proper SHA256 based key from the given method suitable for use as the key GET parameter in a JSONAPI API call.

string

makeURL(string method, array args)

Generates the proper URL for a standard API call the given method and arguments.

string

makeURLMultiple(array methods, array args)

Generates the proper URL for a multiple API call the given method and arguments.

Method Detail

JSONAPI.php at line 30

__construct

public void __construct(mixed host, mixed port, mixed uname, mixed pword, mixed salt)

Creates a new JSONAPI instance.


JSONAPI.php at line 80

call

public array call(string method, array args)

Calls the single given JSONAPI API method with the given args.

Parameters:
method - The name of the JSONAPI API method to call.
args - An array of arguments that are to be passed.
Returns:
An associative array representing the JSON that was returned.

JSONAPI.php at line 114

callMultiple

public array callMultiple(array methods, array args)

Calls the given JSONAPI API methods with the given args.

Parameters:
methods - An array strings, where each string is the name of a JSONAPI API method to call.
args - An array of arrays of arguments that are to be passed.
Throws:
Exception - When the length of the $methods array and the $args array are different, an exception is thrown.
Returns:
An array of associative arrays representing the JSON that was returned.

JSONAPI.php at line 44

createKey

public string createKey(string method)

Generates the proper SHA256 based key from the given method suitable for use as the key GET parameter in a JSONAPI API call.

Parameters:
method - The name of the JSONAPI API method to generate the key for.
Returns:
The SHA256 key suitable for use as the key GET parameter in a JSONAPI API call.

JSONAPI.php at line 58

makeURL

public string makeURL(string method, array args)

Generates the proper URL for a standard API call the given method and arguments.

Parameters:
method - The name of the JSONAPI API method to generate the URL for.
args - An array of arguments that are to be passed in the URL.
Returns:
A proper standard JSONAPI API call URL. Example: "http://localhost:20059/api/call?method=methodName&args=jsonEncodedArgsArray&key=validKey".

JSONAPI.php at line 69

makeURLMultiple

public string makeURLMultiple(array methods, array args)

Generates the proper URL for a multiple API call the given method and arguments.

Parameters:
methods - An array of strings, where each string is the name of the JSONAPI API method to generate the URL for.
args - An array of arrays, where each array contains the arguments that are to be passed in the URL.
Returns:
A proper multiple JSONAPI API call URL. Example: "http://localhost:20059/api/call-multiple?method=[methodName,methodName2]&args=jsonEncodedArrayOfArgsArrays&key=validKey".

JSONAPI: PHP SDK