msyk / fmdataapi Goto Github PK
View Code? Open in Web Editor NEWFMDataAPI is a class developed by PHP to access FileMaker database with FileMaker Data API.
FMDataAPI is a class developed by PHP to access FileMaker database with FileMaker Data API.
Hello,
When iterating over portal records, I discovered that calling the toArray() method on a portal record returns an empty array.
In FileMakerRelation.php line 316 etc, the switch statement has a case for 'OK', 'PORTAL', and 'RECORD'. However my portal record's result property is 'PORTALRECORD'. So there is no matching case and the default value is returned by this method.
Simple pseudo code:
//$record is a FileMakerRelation where the result is RECORD
foreach ($record->getPortalNames() as $portalName) {
foreach ($record->$portalName as $portalRecord) {
$portalRecordArray = $portalRecord->toArray();
print_r($portalRecordArray);
}
}
Expected a dump of the values in each portal record, got empty arrays.
Thank you for this nice library!
Thanks for sharing this code, it has made my request to the API a lot easier, you guys are genius!
Arigato!
Looking at the FileMaker API logs I see that when I use the php script to perform a series of things the script creates a new token per each action, it will be nice to use only one token for all the actions and delete that token/sesion once the script is finished, let me know your thoughts.
Thanks!
Current code in the method getModId()
:
case "RECORD":
case "PORTALRECORD":
if (isset($this->data) && isset($this->data->modId)) {
$value = $this->data->recordId;
}
break;
$value = $this->data->recordId;
should probably be changed to $value = $this->data->modId;
I am enjoying FMDataAPI a lot and cannot thank you enough, today I had the need to show an image that is stored in a FileMaker container, but the simple
== base64_encode(file_get_contents($result->containerFieldName) did not work ==
After searching the web I found a solution that will be nice to have in FMDataAPI so others can also use it to get container data from FileMaker, here it is:
/* STEP 1. create a cookie file /
$ckfile = tempnam("/tmp", "CURLCOOKIE");
/ STEP 2. visit the container URL to set the cookie */
$ch = curl_init($imageURL);
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
/* STEP 3. visit container URL again /
$ch = curl_init($imageURL);
curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
/ STEP 4. process the image data as need it */
$imageData = base64_encode($output);
Once again thanks!
I would like to know total count of records to implement pagination. I discover there is such attribute in dataInfo by examining your source code. Unfortunately "my" response doesn't contain dataInfo key. Is there any way to enable it e.g. in request?
Thanks.
Perhaps I'm using this the wrong way, but I called getPortalNames() after calling getFirstRecord(), and received an error. That is because getNumberedRecord() changes the structure of the internal $data property.
What I did (leaving out the setup code):
`
$records = $fmdb->$layout->query($conditions, null, 1, 1);
$record = $records->getFirstRecord();
$portalNames = $record->getPortalNames(); //error
`
The error message: property_exists(): Argument #1 ($object_or_class) must be of type object|string, array given
File: inter-mediator/fmdataapi/src/Supporting/FileMakerRelation.php
Line: 339
One way to address this would be to change lines 257-259 from this:
$value = new FileMakerRelation( $this->data[$num], $dataInfo, ($this->result == "PORTAL") ? "PORTALRECORD" : "RECORD", $this->errorCode, $this->portalName, $this->restAPI);
into this (by surrounding the first parameter value with []):
$value = new FileMakerRelation( [$this->data[$num]], $dataInfo, ($this->result == "PORTAL") ? "PORTALRECORD" : "RECORD", $this->errorCode, $this->portalName, $this->restAPI);
That way, the array structure of the returned FileMakerRelation object stays the same as before.
Hi,
Concerning Error code 102, is there a way to find which field is missing in a layout? (Error Code: 102, Error Message: Field is missing.)
Or ignore the field that does not exist and proceed with creating and filling a record with other fields that do exist?
Thanks in advance!
I'm sorry, I've forgotten to implement the OAuth process on FM 17 platform. As far as Ver.20 goes, the OAuth feature isn't available. So we need to call '/oauth/getoauthurl' and whaterver. I will start to do it soon.
When using toArray
method defined in https://github.com/msyk/FMDataAPI/blob/master/src/Supporting/FileMakerRelation.php
getting return type error.
This is possibly due to on line number 310, 315, 320 when encoding and decoding the object, json_decode
function is missing second parameter true
. Second parameter set to true
assure that json_decode
always return an array.
Thanks.
Hi,
Hi have 2 servers on version FMS 18 and i upgrade on 18.0.4 yesterday... Since, the FMDataAPI doesn't Work :-(
Uncaught Exception: 2020-07-23 18:58:13 cURL in PHP / Error Code: 7, Error Message: Failed connect to X.X.X.X:443; Connection refused. [URL(POST): https://X.X.X.X:443/fmi/data/vLatest/databases/experts/sessions] in /var/www/vhosts/mydomain.com/httpdocs/FMDataAPI.php:2052
Stack trace:
#0 /var/www/vhosts/mydomain.com/httpdocs/FMDataAPI.php(1920): INTERMediator\FileMakerServer\RESTAPI\Supporting\CommunicationProvider->callRestAPI(Array, false, 'POST', Array, Array)
#1 /var/www/vhosts/mydomain.com/httpdocs/FMDataAPI.php(623): INTERMediator\FileMakerServer\RESTAPI\Supporting\CommunicationProvider->login()
#2 /var/www/vhosts/mydomain.com/httpdocs/do_login.php(31): INTERMediator\FileMakerServer\RESTAPI\Supporting\FileMakerLayout->create(Array)
#3 {main}
thrown in
/var/www/vhosts/mydomain.com/httpdocs/FMDataAPI.php
When passing a limit and/or offset on a related portal the filemaker server responds with an error.
For example:
$filemaker->layout('layout')->query([['id' => 1]], null, 0, 0, ['related_portal' => ['limit' => 5, 'offset' => 0]);
The expected result is a response with a limited amount of portal records. This however results in a error:
{
"messages": [
{
"message": "Unknown parameter(s): _limit.related_portal",
"code": "960"
}
],
"response": {}
}
I have the sample script working fine with the test database, but I'm having trouble connecting with my own database, as I receive HTTP 400 Bad Request across the board. The requests work in Postman, however. Does the wrapper have difficulty handling database files that have spaces in it's filename?
Hi,
Can you connect to files hosted on FileMaker Cloud with your FMDataApi?
Thank
Frank
We have big files (200MB and up) that we want to link on a website.
If we use $file->getContainerData('ContainerFile') we get the error The field 'ContainerFile' is not field name or container field.
.
This piece of code works fine in a database where small images are directly inside the database instead of storing them externally.
How can we receive/download the file from a container where the file is not directly stored inside the database?
Right now my data received via $file->ContainerFile looks like this:
href="file:20180125_151216.gpx\rfilewin:/C:/Users/MyUsername/Downloads/20180125_151216.gpx"
In the Filemaker Server settings under Configuration -> Folder, the "Container Data Folder" is enabled and a folder on my C:\ drive on the server is selected.
Hi,
In the documentation for the function FileMakerLayout::query() ,the parameter $portal is described like this:
The array of the portal's object names. The query result is going to contain portals specified in this parameter. If you want to include all portals, set it null or omit it. Simple case is array('portal1', portal2'), and just includes two portals named 'portal1' and 'portal2' in the query result. If you set the range of records to a portal, you have to build associated array as like: array('portal1' => array('offset'=>1,'range'=>5), 'portal2' => null). The record 1 to 5 of portal1 include the query result, and also all records in portal2 do.
I tried using array('portal1' => array('offset'=>1,'range'=>5)), but I got a "missing array key" error. Looking at the code, it seems to expect something like this: array('portal1' => array('offset'=>1,'limit'=>5)).
However, FileMaker server does not like the request with portal parameters anyway. I will test that some more. Error message from FileMaker Server:
Error Code: 960, Error Message: Unknown parameter(s): _limit.portal1,_offset.portal1.
Is it possible to send multiple script parameters in "script.param", as in a array?
Hi,
There are related fields on the layout
eg. event::start (not in a portal )
but
foreach ($result as $key=> $record ) {
$record->field("start", "event"); // this produce error even if I have a portal
// only way I found it to work was having a portal and accessing it like below
foreach ($record->event as $item) {
print $item->start;
}
}
What am I missing on how to access a related field not in a portal
Thanks
Frank
When executing any API call at the end of the debugging result I keep getting this error:
Recoverable fatal error: Object of class INTERMediator\FileMakerServer\RESTAPI\Supporting\FileMakerRelation could not be converted to string in /FMDataAPI.php on line 1446
Should I leave it and not worry about it?
I tried to fix it but it is beyond my skills at the moment.
I am using php 7.2.127.2.12
I get the following error when I try to fetch the data in a portal (with the FM18 release):
ErrorException (E_ERROR)
Trying to get property 'portalDataInfo' of non-object
I tried it like this: $record->nameoftheportal
This worked with the FM17 version. The portal and the data exists in $record.
Any idea?
Hi, I have the following error when I try $result = $fmdb->layoutname->query();
:
ErrorNumber: 35
Unknown SSL protocol error in connection to xx.xx.com:443
Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.