Documentation

FMDataAPI

Class FMDataAPI is the wrapper of The REST API in Claris FileMaker Server and FileMaker Cloud for AWS.

Tags
link

GitHub Repository

version
30
author

Masayuki Nii nii@msyk.net

copyright

2017-2023 Masayuki Nii (Claris FileMaker is registered trademarks of Claris International Inc. in the U.S. and other countries.)

source

The source code.

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
The error message of curl, text representation of code.
endCommunication()  : mixed
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
The error message of the latest response from the REST API.
getContainerData()  : string
Return the base64 encoded data in container field with with streaming url.
getDatabaseNames()  : 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()  : int
Get the founded record count of just previous query. Usually this method returns the information of the FileMakerRelation class.
getLayoutNames()  : array<string|int, mixed>
Get the list of layout name in database.
getProductInfo()  : object
Get the product information, such as the version, etc. This isn't required to authenticate.
getReturnedCount()  : int
Get the returned record count of just previous query. Usually this method returns the information of the FileMakerRelation class.
getScriptNames()  : array<string|int, mixed>
Get the list of script name in database.
getSessionToken()  : string
The session token earned after authentication.
getTargetTable()  : string
Get the table occurrence name of just previous query. Usually this method returns the information of the FileMakerRelation class.
getTotalCount()  : int
Get the total record count of just previous query. Usually this method returns the information of the FileMakerRelation class.
httpStatus()  : int
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()  : mixed
FileMaker Data API's version is going to be set. If you don't call, the "vLatest" is specified.
setCertValidating()  : mixed
Set to verify the server certificate. The default is to handle as self-signed certificate and doesn't verify.
setDebug()  : mixed
Set the debug mode or not. The debug mode isn't in default.
setFieldHTMLEncoding()  : mixed
Set to true if the return value of the field() method uses htmlspecialchars function.
setGlobalField()  : mixed
Set the value to the global field.
setSessionToken()  : mixed
Set session token
setThrowException()  : mixed
Set to prevent to throw an exception in case of error.
setTimeout()  : mixed
Set the cURL communication timeout in seconds
startCommunication()  : mixed
Start a transaction which is a serial calling of multiple database operations before the single authentication.
useOAuth()  : mixed
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 $password[, string $host = null ][, int $port = null ][, string $protocol = null ][, array<string|int, mixed> $fmDataSource = null ][, bool $isUnitTest = false ]) : mixed
Parameters
$solution : string

The database file name which is just hosting. Every database must have the access privillege 'fmrest' including external data sources.

$user : string

The fmrest privilege accessible user to the database. If you are going to call useOAuth method, you have to specify the data for X-FM-Data-OAuth-Request-Id.

$password : string

The password of above user. If you are going to call useOAuth method, you have to specify the data for X-FM-Data-OAuth-Identifier.

$host : string = 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

FileMaker Server's port number. If omitted, 443 is chosen.

$protocol : string = null

FileMaker Server's protocol name. If omitted, 'https' is chosen.

$fmDataSource : array<string|int, mixed> = 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
Return values
string

The error message of curl.

endCommunication()

Finish a transaction which is a serial calling of any database operations, and logout.

public endCommunication() : mixed

errorCode()

The error code of the latest response from the REST API.

public errorCode() : int

The code 0 means no error, and -1 means error information wasn't return. 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

This error message is associated with FileMaker's error code.

Return values
string

The error messege.

getContainerData()

Return the base64 encoded data in container field with with streaming url.

public getContainerData(string $url) : string
Parameters
$url : string

The container data URL.

Tags
throws
Exception

The exception from the accessToContainer method.

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() : array<string|int, mixed>

This is required to authenticate.

Tags
throws
Exception

In case of any error, an exception arises.

Return values
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(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

The result.

getFoundCount()

Get the founded record count of just previous query. Usually this method returns the information of the FileMakerRelation class.

public getFoundCount() : int
Tags
see
FileMakerRelation::getFoundCount()
Return values
int

The founded record count.

getLayoutNames()

Get the list of layout name in database.

public getLayoutNames() : array<string|int, mixed>
Tags
throws
Exception

In case of any error, an exception arises.

Return values
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() : object
Tags
throws
Exception

In case of any error, an exception arises.

Return values
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 previous query. Usually this method returns the information of the FileMakerRelation class.

public getReturnedCount() : int
Tags
see
FileMakerRelation::getReturnedCount()
Return values
int

The returned record count.

getScriptNames()

Get the list of script name in database.

public getScriptNames() : array<string|int, mixed>
Tags
throws
Exception

In case of any error, an exception arises.

Return values
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 object with the same structure. Ex.: [{"name": "TestScript1","isFolder": false},{"name": "TestScript2","isFolder": false},{"name": "Mentenance", "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 previous query. Usually this method returns the information of the FileMakerRelation class.

public getTargetTable() : string
Tags
see
FileMakerRelation::getTargetTable()
Return values
string

The table name.

getTotalCount()

Get the total record count of just previous query. Usually this method returns the information of the FileMakerRelation class.

public getTotalCount() : int
Tags
see
FileMakerRelation::getTotalCount()
Return values
int

The total record count.

httpStatus()

The HTTP status code of the latest response from the REST API.

public httpStatus() : int
Return values
int

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) : mixed

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) : mixed
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) : mixed
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 htmlspecialchars function.

public setFieldHTMLEncoding(bool $value) : mixed

The default value is FALSE. The nostalgic FileMaker API for PHP was returning htmlspecialchars value of the field. If we want to get the row field data, we had to call getFieldUnencoded method. If this property set to true, FileMakerRelation class's field method (including describing field name directly) returns the value processed with htmlspecialchars. This means kind of compatible mode of 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) : mixed
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
throws
Exception

In case of any error, an exception arises.

setSessionToken()

Set session token

public setSessionToken(string $value) : mixed
Parameters
$value : string

The session token.

setThrowException()

Set to prevent to throw an exception in case of error.

public setThrowException(bool $value) : mixed

The default is true and 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) : mixed
Parameters
$timeout : int

startCommunication()

Start a transaction which is a serial calling of multiple database operations before the single authentication.

public startCommunication() : mixed

Usually most methods login and logout before/after the database operation, and so a little bit time is going to take. The startCommunication() login and endCommunication() logout, and methods between them don't login/out, and it can expect faster operations.

useOAuth()

On the authentication session, username and password are handled as OAuth parameters.

public useOAuth() : mixed

        
On this page

Search results