FileMaker Openfire API Integration

We’ve been using Openfire XMPP at my company since ~2004 and wanted to be able to push out some alerts to our users from FileMaker using our existing chat client. In this example we are just going to send a system broadcast message to all users. For other uses you can find the Full REST API documentation here

What you will need.

  • Latest Version of Openfire XMPP server Link

  • FileMaker Pro or Server

  • Base Elements Plugin Download

  • Time, Love & Tenderness

Installation

  1. Install the Base Elements plugin into FileMaker. More Info.

  2. Login into the Openfire admin console and go to the plugins tab. Click 'available plugins' and install the REST API plugin.

  3. Go to Server > Server Settings and click REST API on the left hand column.

  4. Make sure you’ve enabled the plugin so it can receive API requests.

  5. Enable 'Select Secret key auth' option

We are going to test with curl first to make sure you can connect to the REST API. Fire up your favorite terminal and enter the following.

$ curl -X POST -H "Authorization: <YOUR SECRET KEY AUTH>" -H "Content-Type: application/xml" -d '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><message><body>Hello Neighbor!</body></message>' "http://yourserver.org:9090/plugins/restapi/v1/messages/users"

If everything was configured correctly, you should get a broadcast message with "Hello Neighbor!" as the message.

FileMaker Integration

If your test was successful, lets start crafting our FileMaker script. Due to the API requiring we send some custom headers, we cannot use the built-in Insert URL function, but have to rely on a plugin instead. In this example we will be using the excellent and free Base Elements Plugin.

Create a FM script called Openfire API

Set Variable [ $url; Value:"http://yourserver.org:9090/plugins/restapi/v1/messages/users" ]
Set Variable [ $header; Value:BE_HTTP_Set_Custom_Header ( "Authorization"; "<YOUR SECRET KEY AUTH>") ]
Set Variable [ $header; Value:BE_HTTP_Set_Custom_Header ( "Content-Type"; "application/xml") ]
Set Variable [ $body; Value:"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><message><body>Hello Neightbor!</body></message>" ]
Set Variable [ $post; Value:BE_HTTP_POST ( $url; $body) ]
# Show Trace for Debugging - This is optional although it will help debug any potential issues.
Show Custom Dialog [ Title: "Trace"; Message: BE_Curl_Trace; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
Exit Script[]

Run the script and you should get the same result as when you executed the HTTP POST using curl. Magic!

Thanks

  • An invaluable tool while testing was Postman. If you don’t know about it, you should download and install ASAP. It’s a free plugin for Chrome.

  • The guys over at Ignite Realtime

  • The FileMaker community, especially the guys over at FMSLUG.

  • BaseElements for the free plugin that makes this work.

comments powered by Disqus
FileMaker Openfire API Integration
Share this