Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Add data to a database via HTTP

Featured Replies

  • Newbies

Hello,

Am a complete noob on this tool and can't get my head around a really (should be) basic task.

I have a database "test" with 2 fields, "Measurepoint" and "CO2", have some raspberry pi's that i want to send data via http that is collected to the filemaker server.

For now i would be happy to get proof of concept to add data from the local machine, kind of http://127.0.0.1/test/Measurepoint=1;CO2=20 and this will generate a new post in database ..

Anyone want to point me in the right direction ?

 

Running a FMP16 server on a mac 10.14

I do something similar with my RPi's.

Below is the PHP script I use for this purpose. I have a Windows server that runs FMS, and the scripts are located in "C:\Program Files\FileMaker\FileMaker Server\HTTPServer\conf", your Mac will have a similar folder somewhere.

RPiLayout is the layout that is invoked, and RPiStats is the script that is run.

<?php

if ( substr($_SERVER['REMOTE_ADDR'],0,8) != '192.168.' ) { exit; }

require_once ('FileMaker.php');

$RPi_Start    = isset( $_GET['start'] ) ? preg_replace('/[^0-9]/', '', $_GET['start'] ) : "";
$RPi_Finish   = isset( $_GET['finish'] ) ? preg_replace('/[^0-9]/', '', $_GET['finish'] ) : "";
$RPi_Count    = isset( $_GET['imagecount'] ) ? preg_replace('/[^0-9]/', '', $_GET['imagecount'] ) : "";
$RPi_Case     = isset( $_GET['case'] ) ? preg_replace('/[^a-zA-Z0-9]/', '', $_GET['case'] ) : "";
$RPi_Studio   = isset( $_GET['studio'] ) ? preg_replace('/[^a-zA-Z0-9]/', '', $_GET['studio'] ) : "";
$RPi_Folder   = isset( $_GET['folder'] ) ? preg_replace('/[^a-zA-Z0-9-]/', '', $_GET['folder'] ) : "";

$fm = new FileMaker(); 
$fm->setProperty('database', 'DatabaseName'); 
$fm->setProperty('hostspec', 'http://localhost'); 
$fm->setProperty('username', 'username'); 
$fm->setProperty('password', 'password'); 

$param = '';
foreach( $_GET as $key => $value) {
         if( $param === "" ) {
             $param = $param . $key . "=" . $value;
             } else {
             $param = $param . "&" . $key . "=" . $value;
             }
         }
echo $param."<br>";

if( $RPi_Start === "" or $RPi_Finish === "" or $RPi_Count === "" or $RPi_Case === "" ) {
    if( $RPi_Start === "" ) echo 'missing Start time/date<br>';
    if( $RPi_Finish === "" ) echo 'missing Finish time/date<br>';
    if( $RPi_Count === "" ) echo 'missing Image Count<br>';
    if( $RPi_Case === "" ) echo 'missing Case Name<br>';
    if( $RPi_Studio === "" ) echo 'missing Studio Code<br>';
    if( $RPi_Folder === "" ) echo 'missing Folder Name<br>';
  } else {
    $newPerformScript = $fm->newPerformScriptCommand('RPiLayout', 'RPiStats', $param); 
    $result = $newPerformScript->execute();
    echo 'OK';
  }

?>

RPiStats processes the provided parameters ($param) and creates a new record, populating the fields with values from $param. Nowadays I built a JSON string in PHP and pass that on to FM, which is easier to process. But the above works nonetheless, it's just a bit more work in the script.

Make sure you assign the correct permissions for the username, and enable PHP on the server.

On the RPi I send data to FMS using the below curl command:

curl -f 'http://192.168.1.1/RPiStats.php?start='$START'&finish='$FINISH'&imagecount='$IMAGECOUNT'&case='$CASE'&studio='$STUDIO'&folder='$FOLDER

 

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.