FMDataAPI
in package
Class FMDataAPI is the wrapper of The REST API in Claris FileMaker Server and FileMaker Cloud for AWS.
Tags
Table of Contents
Methods
- __construct() : mixed
- FMDataAPI constructor. If you want to activate OAuth authentication, $user and $password are set as oAuthRequestId and oAuthIdentifier. Moreover, call useOAuth method before accessing layouts.
- curlErrorCode() : int
- The error number of curl, i.e., kind of communication error code.
- curlErrorMessage() : string|null
- The error message of curl, text representation of code.
- endCommunication() : void
- Finish a transaction which is a serial calling of any database operations, and logout.
- errorCode() : int
- The error code of the latest response from the REST API.
- errorMessage() : string|null
- The error message of the latest response from the REST API.
- getContainerData() : string
- Return the base64 encoded data in container field with streaming url.
- getDatabaseNames() : null|array<string|int, mixed>
- Get the information about hosting database. It includes the target database and others in FileMaker Server.
- getFieldHTMLEncoding() : bool
- Detect the return value of the field() method uses htmlspecialchars function or not.
- getFoundCount() : null|int
- Get the founded record count of just a previous query.
- getLayoutNames() : null|array<string|int, mixed>
- Get the list of layout name in a database.
- getProductInfo() : null|object
- Get the product information, such as the version, etc. This isn't required to authenticate.
- getReturnedCount() : null|int
- Get the returned record count of just a previous query.
- getScriptNames() : null|array<string|int, mixed>
- Get the list of script name in database.
- getSessionToken() : string
- The session token earned after authentication.
- getTargetTable() : null|string
- Get the table occurrence name of just a previous query.
- getTotalCount() : null|int
- Get the total record count of just a previous query.
- httpStatus() : int|null
- The HTTP status code of the latest response from the REST API.
- layout() : FileMakerLayout
- Refers the FileMakerLayout object as the proxy of the layout.
- setAPIVersion() : void
- FileMaker Data API's version is going to be set. If you don't call, the "vLatest" is specified.
- setCertValidating() : void
- Set to verify the server certificate. The default is to handle as self-signed certificate and doesn't verify.
- setDebug() : void
- Set the debug mode or not. The debug mode isn't in default.
- setFieldHTMLEncoding() : void
- Set to true if the return value of the field() method uses the htmlspecialchars function.
- setGlobalField() : void
- Set the value to the global field.
- setSessionToken() : void
- Set session token
- setThrowException() : void
- Set to prevent throwing an exception in case of error.
- setTimeout() : void
- Set the cURL communication timeout in seconds
- startCommunication() : void
- Start a transaction which is a serial calling of multiple database operations before the single authentication.
- useOAuth() : void
- On the authentication session, username and password are handled as OAuth parameters.
Methods
__construct()
FMDataAPI constructor. If you want to activate OAuth authentication, $user and $password are set as oAuthRequestId and oAuthIdentifier. Moreover, call useOAuth method before accessing layouts.
public
__construct(string $solution, string $user, string|null $password[, string|null $host = null ][, int|null $port = null ][, string|null $protocol = null ][, array<string|int, mixed>|null $fmDataSource = null ][, bool $isUnitTest = false ]) : mixed
Parameters
- $solution : string
-
The database file name which is just hosting. Every database must have the accessing privilege 'fmrest' including external data sources.
- $user : string
-
The fmrest privilege accessible user to the database. If you’re going to call useOAuth method, you have to specify the data for X-FM-Data-OAuth-Request-Id.
- $password : string|null
-
The password of the above user. This can be null for testing purpose only. Null data is going to replace the string "password". This prevents to be detected as a security issue. On the real solutions, you have to set a valid password string. If you’re going to call useOAuth method, you have to specify the data for X-FM-Data-OAuth-Identifier.
- $host : string|null = null
-
FileMaker Server's host name or IP address. If omitted, 'localhost' is chosen. The value "localserver" tries to connect directory 127.0.0.1, and you don't have to set $port and $protocol.
- $port : int|null = null
-
FileMaker Server's port number. If omitted, 443 is chosen.
- $protocol : string|null = null
-
FileMaker Server's protocol name. If omitted, 'https' is chosen.
- $fmDataSource : array<string|int, mixed>|null = null
-
Authentication information for external data sources. Ex. [{"database"=>"<databaseName>", "username"=>"
", "password"=>" "}]. If you use OAuth, "oAuthRequestId" and "oAuthIdentifier" keys have to be spedified. - $isUnitTest : bool = false
-
If it's set to true, the communication provider just works locally.
curlErrorCode()
The error number of curl, i.e., kind of communication error code.
public
curlErrorCode() : int
Return values
int —The error number of curl.
curlErrorMessage()
The error message of curl, text representation of code.
public
curlErrorMessage() : string|null
Return values
string|null —The error message of curl.
endCommunication()
Finish a transaction which is a serial calling of any database operations, and logout.
public
endCommunication() : void
Tags
errorCode()
The error code of the latest response from the REST API.
public
errorCode() : int
Code 0 means no error, and -1 means error information wasn't returned. This error code is associated with FileMaker's error code.
Return values
int —The error code.
errorMessage()
The error message of the latest response from the REST API.
public
errorMessage() : string|null
This error message is associated with FileMaker's error code.
Return values
string|null —The error message.
getContainerData()
Return the base64 encoded data in container field with streaming url.
public
getContainerData(string $url) : string
Parameters
- $url : string
-
The container data URL.
Tags
Return values
string —The base64 encoded data in container field.
getDatabaseNames()
Get the information about hosting database. It includes the target database and others in FileMaker Server.
public
getDatabaseNames() : null|array<string|int, mixed>
This is required to authenticate.
Tags
Return values
null|array<string|int, mixed> —The information of hosting databases. Every element is an object and just having 'name' property.Ex.: [{"name": "TestDB"},{"name": "sample_db"}]
getFieldHTMLEncoding()
Detect the return value of the field() method uses htmlspecialchars function or not.
public
getFieldHTMLEncoding() : bool
Return values
bool —The result.
getFoundCount()
Get the founded record count of just a previous query.
public
getFoundCount() : null|int
Usually this method returns the information of the FileMakerRelation class.
Tags
Return values
null|int —The founded record count.
getLayoutNames()
Get the list of layout name in a database.
public
getLayoutNames() : null|array<string|int, mixed>
Tags
Return values
null|array<string|int, mixed> —The information of layouts in the target database. Every element is an object and just having 'name' property. Ex.: [{"name": "person_layout"},{"name": "contact_to"},{"name": "history_to"}...]
getProductInfo()
Get the product information, such as the version, etc. This isn't required to authenticate.
public
getProductInfo() : null|object
Tags
Return values
null|object —The information of this FileMaker product. Ex.: {'name' => 'FileMaker Data API Engine', 'buildDate' => '03/27/2019', 'version' => '18.0.1.109', 'dateFormat' => 'MM/dd/yyyy', 'timeFormat' => 'HH:mm:ss', 'timeStampFormat' => 'MM/dd/yyyy HH:mm:ss'}.
getReturnedCount()
Get the returned record count of just a previous query.
public
getReturnedCount() : null|int
Usually this method returns the information of the FileMakerRelation class.
Tags
Return values
null|int —The returned record count.
getScriptNames()
Get the list of script name in database.
public
getScriptNames() : null|array<string|int, mixed>
Tags
Return values
null|array<string|int, mixed> —The information of scripts in the target database. Every element is an object and having 'name' property. The 'isFolder' property is true if it's a folder item, and it has the 'folderScriptNames' property and includes an object with the same structure. Ex.: [{"name": "TestScript1","isFolder": false},{"name": "TestScript2","isFolder": false},{"name": "Maintenance", "isFolder": true, "folderScriptNames": [{"name": "DataImport","isFolder": false}]}]
getSessionToken()
The session token earned after authentication.
public
getSessionToken() : string
Return values
string —The session token.
getTargetTable()
Get the table occurrence name of just a previous query.
public
getTargetTable() : null|string
Usually this method returns the information of the FileMakerRelation class.
Tags
Return values
null|string —The table name.
getTotalCount()
Get the total record count of just a previous query.
public
getTotalCount() : null|int
Usually this method returns the information of the FileMakerRelation class.
Tags
Return values
null|int —The total record count.
httpStatus()
The HTTP status code of the latest response from the REST API.
public
httpStatus() : int|null
Return values
int|null —The HTTP status code.
layout()
Refers the FileMakerLayout object as the proxy of the layout.
public
layout(string $layout_name) : FileMakerLayout
If the layout doesn't exist, no error arises here. Any errors might arise on methods of FileMakerLayout class.
Parameters
- $layout_name : string
-
Layout name.
Return values
FileMakerLayout —object which is proxy of FileMaker's layout.
setAPIVersion()
FileMaker Data API's version is going to be set. If you don't call, the "vLatest" is specified.
public
setAPIVersion(int $vNum) : void
As far as FileMaker 18 supports just "v1", no one has to call this method.
Parameters
- $vNum : int
-
FileMaker Data API's version number.
setCertValidating()
Set to verify the server certificate. The default is to handle as self-signed certificate and doesn't verify.
public
setCertValidating(bool $value) : void
Parameters
- $value : bool
-
Turn on to verify the certificate if the value is true.
setDebug()
Set the debug mode or not. The debug mode isn't in default.
public
setDebug(bool $value) : void
Parameters
- $value : bool
-
set the debug mode if the value is true.
setFieldHTMLEncoding()
Set to true if the return value of the field() method uses the htmlspecialchars function.
public
setFieldHTMLEncoding(bool $value) : void
The default value is FALSE. The nostalgic FileMaker API for PHP was returning the htmlspecialchars value of the field. If we want to get the row field data, we had to call the getFieldUnencoded method. If this property is set to true, FileMakerRelation class's field method (including describing field name directly) returns the value processed with the htmlspecialchars. This means kind of compatible mode to FileMaker API for PHP. This feature works whole the FMDataAPI library.
Parameters
- $value : bool
-
Turn on to verify the certificate if the value is true.
setGlobalField()
Set the value to the global field.
public
setGlobalField(array<string|int, mixed> $fields) : void
Parameters
- $fields : array<string|int, mixed>
-
Associated array contains the global field names (Field names must be Fully Qualified) and its values. Keys are global field names and values is these values.
Tags
setSessionToken()
Set session token
public
setSessionToken(string $value) : void
Parameters
- $value : string
-
The session token.
setThrowException()
Set to prevent throwing an exception in case of error.
public
setThrowException(bool $value) : void
The default is true, so an exception is going to throw in error.
Parameters
- $value : bool
-
Turn off to throw an exception in case of error if the value is false.
setTimeout()
Set the cURL communication timeout in seconds
public
setTimeout(int $timeout) : void
Parameters
- $timeout : int
startCommunication()
Start a transaction which is a serial calling of multiple database operations before the single authentication.
public
startCommunication() : void
Usually most methods login and logout before/after the database operation, and so a little bit of time is going to take. The startCommunication() login and endCommunication() logout, and methods between them don't log in/out, and it can expect faster operations.
Tags
useOAuth()
On the authentication session, username and password are handled as OAuth parameters.
public
useOAuth() : void