fmAdminAPI Constructor
function __construct($host, $username, $password, $options = array())
Constructor for fmAdminAPI.
Parameters:
(string) $host The host name typically in the format of https://HOSTNAME
(string) $username The user name of the account to authenticate with
(string) $password The password of the account to authenticate with
(array) $options Optional parameters
['version'] Version of the API to use (1, 2, etc. or 'Latest')
['cloud'] Set to true if you're using FileMaker Cloud
Token management - typically you choose none or one of the following 3 options:
['storeTokenInSession'] and ['sessionTokenKey']
['tokenFilePath']
['token']
['storeTokenInSession'] If true, the token is stored in the $_SESSION[] array (defaults to true)
['sessionTokenKey'] If ['storeTokenInSession'] is true, this is the key field to store
the token in the $_SESSION[] array. Defaults to 'FM-Admin-Session-Token'.
['tokenFilePath'] Where to read/write a file containing the token. This is useful
when you are called as a web hook and do not have a typical
browser-based session to rely on. You should specify a path that
is NOT visible to the web. If you need to encrypt/decrypt the token
in the file, override getTokenFromStorage() and setToken().
['token'] The token from a previous call. This will normally be pulled
from the $_SESSION[] or ['tokenFilePath'], but in cases where
you need to store it somewhere else, pass it here. You are responsible
for calling the getToken() method after a successful call to retrieve
it for your own storage.
['authentication'] set to 'oauth' for oauth authentication
['oauthID'] oauthID
['oauthIdentifier'] oauth identifier
Returns:
The newly created object.
Example:
$fm = new fmAdminAPI($host, $username, $password);
fmAdminAPI::apiLogin()
function apiLogin()
Create a new session on the server. Authentication parameters were previously passed to the __construct method.
Normally you will not call this method as the other apiNNNNNN() methods take care of logging in when appropriate.
By default, the authentication token is stored within this class and reused for all further calls. If the server
replies that the token is not longer valid (FM_ERROR_INSUFFICIENT_PRIVILEGES - 9), this class will automatically login
again to get a new token.
The server expires a timer after approximately 15 minutes, but the timer is reset each time you make a call to
the server. You should not assume it is always 15 minutes; a later version of FileMaker Server may change this
time. Let this class handle the expiration in a graceful manner.
Parameters:
None
Returns:
An JSON-decoded associative array of the API result. Typically:
['response'] If the call succeeds, the ['token'] element contains the authentication token.
['messages'] Array of code/message pairs
Example:
$fm = new fmAdminAPI($database, $host, $username, $password);
$apiResult = $fm->apiLogin();
if (! $fm->getIsError($apiResult)) {
...
}
Create a new session
fmAdminAPI::apiLogout()
function apiLogout()
Logs out of the current session and clears the username, password, and authentication token.
Normally you will not call this method so that you can keep re-using the authentication token for future calls.
Only logout if you know you are completely done with the session. This will also clear the stored username/password.
Parameters:
None
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiLogout();
if (! $fm->getIsError($apiResult)) {
...
}
Log out of the session
fmAdminAPI::apiGetServerInfo()
function apiGetServerInfo()
Get information about the server. You do not need to authenticate to get this information.
Parameters:
None
Returns:
An JSON-decoded associative array of the API result. Typically:
['data'] An array of data
['result'] 0 if successful else an error code
Example:
$fm = new fmAdminAPI($host);
$apiResult = $fm->apiGetServerInfo();
if (! $fm->getIsError($apiResult)) {
...
}
Get information about the server
fmAdminAPI::apiGetServerStatus()
function apiGetServerStatus()
Get the status of the server
Parameters:
(array) $data An array of options to set in the general configuration.
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
['running'] 1 if the server is running
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiGetServerStatus();
if (! $fm->getIsError($apiResult)) {
...
}
Get the server status
fmAdminAPI::apiSetServerStatus()
function apiSetServerStatus($data)
Set the status of the server
Parameters:
(array) $data An array of options to set. Currently 'running' is the only option.
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
['running'] 1 if the server is running
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiSetServerStatus($data);
if (! $fm->getIsError($apiResult)) {
...
}
fmAdminAPI::apiGetLog($url, $type, $format)
function apiGetLog($type, $format, $url = '')
Get a FileMaker Server log.
This is an 'extension' to the Admin API.
To make this work, you must be running the fmPDA class files on your FMS server *or* install
the 'get_fms_log.php' file on your FMS server. Both this method andget_fms_log.php will authenticate
through the Admin API by sending a apiGetServerStatus() request.
Parameters:
(string) type The type of log to return
'access'
'event'
'fmdapi'
'stderr'
'stdout'
'topcallstats'
'wpedebug'
'wpe'
(string) format The format of the log data:
'raw' The contents of the file as read from disk (default)
'html' Convert \r and \n to HTML <br> tags
'html-table' HTML table
(string) url If blank, fmPDA must reside on the same server as FileMaker server
so that it has access to the log files directory. If fmPDA is on a separate server
you will need to install get_fms_log.php resides on your FMS server and then pass
the URL to that location here.
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
['message'] The error message
['log'] The log file, in whatever form specified by type in the request payload
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiGetLog($url, $type, $format);
if (! $fm->getIsError($apiResult)) {
...
}
Get Server 'Event' Log
fmAdminAPI::apiGetPHPConfiguration()
function apiGetPHPConfiguration()
Get the PHP configuration for the server.
Parameters:
None
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
['enabled'] 1 if PHP is enabled, 0 otherwise
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiGetPHPConfiguration();
if (! $fm->getIsError($apiResult)) {
...
}
Get the PHP configuration
fmAdminAPI::apiSetPHPConfiguration()
function apiSetPHPConfiguration($data)
Set the PHP configuration on the server.
Parameters:
(array) $data An array of options to set in the PHP configuration.
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$option = array();
$option[ ... ] = '';
$apiResult = $fm->apiSetPHPConfiguration($data);
if (! $fm->getIsError($apiResult)) {
...
}
fmAdminAPI::apiGetXMLConfiguration()
function apiGetXMLConfiguration()
Get the XML configuration for the server.
Parameters:
None
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
['enabled'] 1 if XML is enabled, 0 otherwise
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiGetXMLConfiguration();
if (! $fm->getIsError($apiResult)) {
...
}
Get the XML configuration
fmAdminAPI::apiSetXMLConfiguration()
function apiSetXMLConfiguration($data)
Get the XML configuration for the server.
Parameters:
(array) $data An array of options to set in the XML configuration. 'enabled' is currently the only option.
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$option = array();
$option['enabled'] = 'true';
$apiResult = $fm->apiSetXMLConfiguration($data);
if (! $fm->getIsError($apiResult)) {
...
}
fmAdminAPI::apiGetServerGeneralConfiguration()
function apiGetServerGeneralConfiguration()
Get the server's general configuration
Parameters:
None
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiGetServerGeneralConfiguration();
if (! $fm->getIsError($apiResult)) {
...
}
Get the Server's General Configuration
fmAdminAPI::apiSetServerGeneralConfiguration()
function apiSetServerGeneralConfiguration($data)
Get the server's security configuration
Parameters:
(array) $data An array of options to set in the general configuration.
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiSetServerGeneralConfiguration($data);
if (! $fm->getIsError($apiResult)) {
...
}
fmAdminAPI::apiGetServerSecurityConfiguration()
function apiGetServerSecurityConfiguration()
Get the server's security configuration
Parameters:
None
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiGetServerSecurityConfiguration();
if (! $fm->getIsError($apiResult)) {
...
}
Get the Server's Security Configuration
fmAdminAPI::apiSetServerSecurityConfiguration()
function apiSetServerSecurityConfiguration($data)
Get the server's security configuration
Parameters:
(array) $data An array of options to set in the general configuration.
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiSetServerSecurityConfiguration($data);
if (! $fm->getIsError($apiResult)) {
...
}
fmAdminAPI::apiListDatabases()
function apiListDatabases()
List the databases on the server
Parameters:
None
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiListDatabases();
if (! $fm->getIsError($apiResult)) {
...
}
List the databases
fmAdminAPI::apiPerformOnDatabases($status)
function apiPerformOnDatabases($status)
Perform an operation on all databases on the server
Parameters:
(string) $status The new status: OPENED, PAUSED, RESUMED, CLOSED
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiPerformOnDatabases(1, 'CLOSED');
if (! $fm->getIsError($apiResult)) {
...
}
Open all databases on the server.
Close all databases on the server.
Resume all databases on the server.
Pause all databases on the server.
Close all databases on the server.
Resume all databases on the server.
Pause all databases on the server.
fmAdminAPI::apiPerformOnDatabase($databaseID, $status, $password = '', $messageText = '', $force = '')
function apiPerformOnDatabase($databaseID, $status, $password = '', $messageText = '', $force = '')
Perform an operation on a database.
Parameters:
(integer) $databaseID The database ID
(string) $status The new status: OPENED, PAUSED, RESUMED, CLOSED
(array) $options An associative array with the following options:
['password'] The encryption password for the database.
['messageText'] The text message to send to the client being disconnected. Required and allowed only if status = CLOSED.
['force'] Specify this parameter to force close database. Allowed only if status = CLOSED.
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiPerformOnDatabase(1, 'CLOSED');
if (! $fm->getIsError($apiResult)) {
...
}
Open database with ID 1.
Close database with ID 1.
Resume database with ID 1.
Pause database with ID 1.
Close database with ID 1.
Resume database with ID 1.
Pause database with ID 1.
fmAdminAPI::apiListClients()
function apiListClients()
List all currently connected clients
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiListClients();
if (! $fm->getIsError($apiResult)) {
...
}
Get a list of currently connected clients
fmAdminAPI::apiDisconnectClient()
function apiDisconnectClient($clientID, $message = '', $graceTime = '')
Disconnect a client
Parameters:
(integer) $clientID The client ID
(string) The message to send
(integer) The number of seconds to wait before disconnecting (0-3600)
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiDisconnectClient($data);
if (! $fm->getIsError($apiResult)) {
...
}
fmAdminAPI::apiSendMessageToClient()
function apiSendMessageToClient($clientID, $message)
Send a messge to a client
Parameters:
(integer) $clientID The client ID
(string) The message to send
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiDisconnectClient($data);
if (! $fm->getIsError($apiResult)) {
...
}
fmAdminAPI::apiListSchedules()
function apiListSchedules()
Get a list of schedules.
Parameters:
None
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiListSchedules();
if (! $fm->getIsError($apiResult)) {
...
}
Get a list of schedules
fmAdminAPI::apiCreateSchedule()
function apiCreateSchedule($data)
Create a new schedule
Parameters:
(array) $data An array of options to set specifying the schedule.
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiCreateSchedule($data);
if (! $fm->getIsError($apiResult)) {
...
}
fmAdminAPI::apiDeleteSchedule()
function apiDeleteSchedule($scheduleID)
Delete a schedule
Parameters:
(integer) $scheduleID The schedule ID
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
['schedules'] The deleted schedule
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiDeleteSchedule($scheduleID);
if (! $fm->getIsError($apiResult)) {
...
}
fmAdminAPI::apiDuplicateSchedule()
function apiDuplicateSchedule($scheduleID)
Duplicate a schedule
Parameters:
(integer) $scheduleID The schedule ID
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
['schedules'] The schedule that was duplicated
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiDuplicateSchedule($scheduleID);
if (! $fm->getIsError($apiResult)) {
...
}
fmAdminAPI::apiEnableSchedule()
function apiEnableSchedule($scheduleID)
Enable a schedule
Parameters:
(integer) $scheduleID The schedule ID
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
['schedules'] The schedule that was enabled
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiEnableSchedule($scheduleID);
if (! $fm->getIsError($apiResult)) {
...
}
fmAdminAPI::apiDisableSchedule()
function apiDisableSchedule($scheduleID)
Disable a schedule
Parameters:
(integer) $scheduleID The schedule ID
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
['schedules'] The schedule that was disabled
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiDisableSchedule($scheduleID);
if (! $fm->getIsError($apiResult)) {
...
}
fmAdminAPI::apiRunSchedule()
function apiRunSchedule($scheduleID)
Run a schedule
Parameters:
(integer) $scheduleID The schedule ID
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
['schedules'] The schedule that was executed
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiRunSchedule($scheduleID);
if (! $fm->getIsError($apiResult)) {
...
}
fmAdminAPI::apiGetSchedule()
function apiGetSchedule($scheduleID)
Get a schedule
Parameters:
(integer) $scheduleID The schedule ID
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
['schedules'] The schedule
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiGetSchedule($scheduleID);
if (! $fm->getIsError($apiResult)) {
...
}
Get a schedule
fmAdminAPI::apiSetSchedule()
function apiSetSchedule($scheduleID, $data)
Set a schedule
Parameters:
(integer) $scheduleID The schedule ID
(array) $data An array of options to set specifying the schedule.
Returns:
An JSON-decoded associative array of the API result. Typically:
['result'] 0 if successful else an error code
['schedules'] The schedule
...
Example:
$fm = new fmAdminAPI($host, $username, $password);
$apiResult = $fm->apiSetSchedule($scheduleID, $data);
if (! $fm->getIsError($apiResult)) {
...
}