Actr_StartHTTPServer |
Starts the built-in HTTP Server. This web server will trigger a script when data arrives.
Syntax
Actr_StartHTTPServer ( switches ; fileName ; scriptName ; { password ;
{ serverName } } )
Parameters
switches | determine the behavior of this command |
filename | the name of the file which contains the script to trigger when a HTTP request arrives |
scriptname | specifies the name of the script to trigger when a HTTP request arrives |
password | (optional) a password which the sender needs to add to the HTTP request |
serverName | (optional, macOS only) the name of the SSL Certificate and server in the keychain |
Switches
Switches can be empty or one of the following:
-Defaultportnumber | use the default port number of the Activator (TCP port 54242) |
-Portnumber=xxx | use the specified portnumber xxx |
You can also add these switches:
-AllowAnyPostedText | allow any text to be posted to the url "/posttext.html" |
-RunSecureServer | starts a Secure (HTTPS) Server. |
Returned Result
Data type returned
Error code
Result
The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 | no error | |
$$-50 | paramErr | there was an error with a parameter |
$$-4228 | kErrPortNrOutOfRange | the port number is out of range |
$$-4407 | kErrSSLCertificateNotFound | the SSL Certificate could not be found |
$$-4408 | kErrSSLPrivateKeyNotFound | the Private Key for this SSL Server could not be found |
$$-4409 | kErrNotImplementedOn32bit | the Secure (HTTPS) Server functionality is not available when running on a 32-bit version of FileMaker |
Other errors may be returned.
Originated in
Activator Plug-in 3.0
Compatibility
FileMaker Pro 17 to 2023
Considerations
Only HTTP requests which are posted to the right web page will trigger the script. Other requests (for example for the index.html page) do not trigger a script but a default web page will be returned to the remote client..
Remote clients can trigger a script with a URL like this:
http://www.example.com:54242/triggerscript.html?yourText=someText
See the Actr_SetHTTPResponse function and the HTTPResponse.fmp12 example file for more detailed information on how to send a custom response.
When the URL contains a password parameter, the password will be removed from the result returned by
Actr_GetEventInfo ("-GetURL" ; $EeventID)
This function also lets the Activator Plug-in act as an Image Upload Server. See the UploadData.fmp12 example file for more detailed information. You can also send text only to the plug-in.
To upload text posted to the url “/posttext.html” you need to wrap it in tags like this:
<TROI_TEXT_UTF8>
your UTF8 formatted text
</TROI_TEXT_UTF8>
New for v8.0: If you want to allow allow any text to be uploaded to the upload server add the switch “-AllowAnyPostedText” when starting the server.
New for v9.0: by adding the switch “-RunSecureServer” you can now start a Secure (HTTPS) Server. Note that for running a secure server you need to install a SSL Certificate. This can be a self signed certificate for testing purposes.
For HTTPS you may want to specify port number 443, which is the default port number for HTTPS as defined by the Internet Engineering Task Force. This port may already be in use by another web server on your computer.
On macOS you can specify the name of the SSL Certificate with the (optional) serverName parameter. If serverName is empty the plug-in will use “HTTPS_Server_TroiActivatorPlugin” as server name.
The Secure Server (HTTPS) functionality is not available when running on a 32-bit version of FileMaker Pro.
On macOS the plug-in will make the HTTP server known via Bonjour as “Troi Activator Upload Server”, allowing for easy discovery.
When you are hosting files for WebDirect: see the WebDirect_UploadImage.fmp12 example file.
Example
Set Field [ result ; Actr_StartHTTPServer ( "-Unused" ; "Upload.fmp12" ;
"HTTP_TriggerScript" ; "secret" ) ]
This command starts the HTTP Server. When (image) data comes in, it will trigger the script “HTTP_TriggerScript” in file “Upload.fmp12”. Note that this example is somewhat simplified, normally you should not use a hardcoded filename like in the above example.
Example 2
Add the following script steps:
Set Variable [ $Password ; "secret" ]
Set Variable [ $Switches ; "-Portnumber=12345 -RunSecureServer" ]
Set Variable [ Result ; Actr_StartHTTPServer ( $Switches ; Get ( FileName ) ;
"HTTP_TriggerScript" ; $Password ; "Acme Inc Server" ) ]
This command will start a Secure (HTTPS) Server, with the server listening on port 12345. Users can now securely send images or text data from other computers or for example an iPhone or iPad.
Used in example files
HTTPResponse.fmp12
UploadData.fmp12
WebDirect_UploadImage.fmp12
Related functions
Actr_GetEventInfo |
Actr_SetHTTPResponse |
Actr_StopHTTPServer |
Related script step
Start HTTP Server |
Related topics
Activator Plug-in online help (overview)