Documentation

api_functions.php

Table of Contents

Functions

get_api_key()  : string|false
Return a private scramble key for this user.
check_api_key()  : bool
Check a query is signed correctly.
execute_api_call()  : bool|string
Execute the specified API function.
get_session_api_key()  : string
Return the session specific key for the given user.
api_login()  : string|false
API login function
api_validate_upload_url()  : bool
Validate URL supplied in APIs create resource or upload by URL. Requires the URL hostname to be added in config $api_upload_urls
assert_post_request()  : array<string|int, mixed>
Assert API request is using POST method.
assert_content_type()  : array<string|int, mixed>
Assert API sent the expected content type.
api_get_daily_stat_summary()  : mixed
Return a summary of daily statistics

Functions

get_api_key()

Return a private scramble key for this user.

get_api_key(int $user) : string|false
Parameters
$user : int

The user ID

Return values
string|false

check_api_key()

Check a query is signed correctly.

check_api_key(string $username, string $querystring, string $sign[, string $authmode = "userkey" ]) : bool
Parameters
$username : string

The username of the calling user

$querystring : string

The query being passed to the API

$sign : string

The signature to check

$authmode : string = "userkey"

The type of key being provided (user key or session key)

Return values
bool

execute_api_call()

Execute the specified API function.

execute_api_call(string $query[, bool $pretty = false ]) : bool|string
Parameters
$query : string

The query string passed to the API

$pretty : bool = false

Should the JSON encoded result be 'pretty' i.e. formatted for reading?

Return values
bool|string

get_session_api_key()

Return the session specific key for the given user.

get_session_api_key(int $user) : string
Parameters
$user : int

The user ID

Return values
string

api_login()

API login function

api_login(string $username, string $password) : string|false
Parameters
$username : string

Username

$password : string

Password to validate

Return values
string|false

FALSE if invalid, session API key if valid

api_validate_upload_url()

Validate URL supplied in APIs create resource or upload by URL. Requires the URL hostname to be added in config $api_upload_urls

api_validate_upload_url(string $url) : bool
Parameters
$url : string

The full URL.

Return values
bool

Returns true if a valid URL is found.

assert_post_request()

Assert API request is using POST method.

assert_post_request(bool $force) : array<string|int, mixed>
Parameters
$force : bool

Force the assertion

Return values
array<string|int, mixed>

Returns JSend data back ajax_functions.php if not POST method

assert_content_type()

Assert API sent the expected content type.

assert_content_type(string $expected, string $received_raw) : array<string|int, mixed>
Parameters
$expected : string

MIME type

$received_raw : string

MIME type

Return values
array<string|int, mixed>

Returns JSend data back ajax_functions.php if received Content-Type is unexpected

api_get_daily_stat_summary()

Return a summary of daily statistics

api_get_daily_stat_summary([int $days = 30 ]) : mixed
Parameters
$days : int = 30

The number of days - note max 365 days as only the current and previous year's data is accessed.

On this page

Search results