OlgerDiekstra Posted November 8, 2018 Posted November 8, 2018 I'm hoping this will be of help to someone. In my environment I use CWP to receive SMS status updates from our SMS gateway, allow customers to opt out of SMS marketing messages, and receive Balance requests from customer via SMS. I use two small PHP scripts, one for handling the SMS status messages and one for receiving customer requests (Opt-out or Balance). The problem I've encountered (and not fixed yet) is that sometimes the link between CWP and the FileMaker DB goes south. The php scripts can detect this, but the submitting party (all these requests come from our SMS gateway) can't alert me that there is a problem. So, in order to detect whether the entire path from php/CWP to the DB works correctly, I created a little php script that tells me whether things are working or not. <?php require_once ('FileMaker.php'); $fm = new FileMaker(); $fm->setProperty('database', 'Your Database'); $fm->setProperty('hostspec', 'http://localhost'); $fm->setProperty('username', 'user'); $fm->setProperty('password', 'password'); $script = $fm->newPerformScriptCommand('Valid Layout', 'Valid Script'); $result = $script->execute(); if (FileMaker::isError($result)) { http_response_code(404); echo "ERROR"; } else { http_response_code(200); echo "OK"; } //print("<pre>".print_r($result,true)."</pre>"); ?> The above script (provided you have set the correct database name, user and password, as well as specified a valid layout and script to call, and the specified user has access to both layout and script) will return 'OK' or 'ERROR' in the browser and set the http status code to either 200 (success) or 404 (cannot find). This means that the entire path (php/CWP FileMaker/DB/script) is tested and works if 200 is returned. This script can be expanded (ie in my case I want to test status messages can be delivered, opt-out and balance sms's can be received) to only return OK 200 if all tests succeed. This can then be used with a tool such as http://statuscake.com to monitor the result of the script and alert via SMS or email when the result is 404. StatusCake has both free and paid subscriptions and monitors from several datacenters around the world. The free subscription has limitations, but the above setup works just fine.
Recommended Posts