๐Ÿ“ฆ Class iml\tinyapi


๐Ÿ”ถ Properties

(none)

๐Ÿ”ท Methods

๐Ÿ”น public __construct()

constructor

Return: ``

Parameters: 1

Parameter Type Description
<optional> array $aRequirements = [] array optional: requirements with subkeys methods ips

๐Ÿ”น public allowIPs()

Set allowed ip addresses by a given list of regex

Return: bool

Parameters: 1

Parameter Type Description
<required> array $aIpRegex array array aIpRegex array of regex

๐Ÿ”น public allowMethods()

Set allowed http methods

Return: bool

Parameters: 1

Parameter Type Description
<required> array $aMethods array array aMethods array of strings containing GET, PUT, POST, DELETE, OPTIONS

๐Ÿ”น public allowUsers()

Set allowed users

Return: bool

Parameters: 1

Parameter Type Description
<required> array $aUsers array array aUsers array of allowed users; key= username (โ€™โ€™ or userid); subkeys: - โ€˜passwordโ€™; value = password hash (BASIC AUTH) and/ or - โ€˜secretโ€™; clear text for hmac

๐Ÿ”น public appendData()

Append response dataIf no key as 2nd param is given the given array will be added as new array element.With a given key the key will be used to set data (existing key will be replaced)

Return: bool

Parameters: 2

Parameter Type Description
<required> mixed $aData mixed additional response data
<optional> string $sKey = โ€˜โ€™ string optional: use key

๐Ÿ”น public checkIp()

Check allowed ip addresses by a given list of regex.It aborts if no ip address was detected.If access is not allowed it sends a 401 header and aborts.

Return: bool

Parameters: 0

๐Ÿ”น public checkMethod()

Check allowed http methods

Return: bool

Parameters: 1

Parameter Type Description
<optional> array $aMethods = [] array array aMethods optional: array of strings containing GET, PUT, POST, DELETE, OPTIONS

๐Ÿ”น public checkUser()

Get an authenticated user and return a detected username as string.Checks are done in that sequence- sent basic auth (base64 encoded :); remark it can override the user of a already authenticated user- sent generated hmac hashsum(:)- already made basic auth from browser- test if anonymous access is allowedRemark: this is a pre check. Your app can make further check like checka role if the found user has access to a function.@example:$oYourApp->setUser($oTinyApi->checkUser());

Return: string

Parameters: 0

๐Ÿ”น public sendError()

Send error message using the sendJson method.

Return: void

Parameters: 2

Parameter Type Description
<required> int $iHttpstatus int http statuscode
<required> string $sErrormessage string string with error message

๐Ÿ”น public sendJson()

Send API response:set content type in http response header and transform data to jsonand stop.

Return: void

Parameters: 1

Parameter Type Description
<optional> array $aData = [] array array of data to send

๐Ÿ”น public setData()

Set response data; โ€œshouldโ€ be an array

Return: bool

Parameters: 1

Parameter Type Description
<required> array $aData array response data

๐Ÿ”น public setPretty()

Set response data; โ€œshouldโ€ be an array

Return: bool

Parameters: 1

Parameter Type Description
<required> bool $bPretty bool response data

๐Ÿ”น public stopIfOptions()

If http method is OPTIONS, send json and stop.

Return: void

Parameters: 0


Generated with Axels PHP class doc parser.