Publish any Content on Facebook using Mendix
Publish any Content on Facebook using Mendix

Publish any Content on Facebook using Mendix

Heena S
Published in
4 min readFeb 22, 2022

--

With roughly 2.91 billion monthly active users at the end of 2021, Facebook is the most used online social network worldwide. Naturally, the ability to post content to Facebook can be a great asset to the success of your app.

We can post a variety of content on Facebook from other apps. Similarly, we can do the same from a Mendix app to Facebook. This feature helps drive traffic towards your app, especially for e-commerce sales or Retailers.

In the short blog, I will cover how to set up your app on Facebook. I then move on to show you how to integrate this functionality into your Mendix app, using Facebook’s RESTful API.

Creating the app on Facebook

1. Create a Facebook developer account with your Facebook username and password and Create a Public page in your Facebook account.

2. Go to MyApps Facebook developer account. Create a new app and select the type of app, give name details.

3. Go to Developer Tools and select Graph API Explorer.

4. Add required permissions and Generate Access Token, You can use this access token to access Facebook from Mendix but it will expire soon.

5. To get a Long-lived Access token. Copy the Short-Lived access token and paste it into Debug access token and debug it and get the extended access token.

The Mendix side

To post an image on Facebook from Mendix, you need a Page ID.

Store the Long-lived access token and page ID, in the database. (Consider using the Encryption Marketplace Module to securely store these details)

Call REST activity to get Page Access Token and Then Pass the Page Access Token to Another REST call Activity to Post Image in Facebook.

The Long-Lived access token is used here to GET/POST in the Custom HTTP headers tab as Authorization Bearer Key.

Getting Page Access

To Get Page Access you need a Page ID. The Page ID defines which Facebook page you are going to Publish to.

Open your Facebook Public page, in the URL, you will get the Page ID.

  1. Create JSON structure and store the response.

2. While creating import mapping select elements, here I need only the page access token.

3. Create a new non persistable entity to store the page access token

After you get the Page Access Token, you will be able to publish any content on your Facebook page from Mendix, by including it in your location URL as shown below.

Good to go!

Now you’re set up to publish any content to Facebook. When the microflow triggers you will receive a successful response. To make sure it worked, check the recent post on the Facebook page which was published via Mendix.

I hope you found this interesting and useful, please feel free to ask any questions in the comments here.

Read more

From the Publisher -

If you enjoyed this article you can find more like it on our Medium page. For great videos and live sessions, you can go to MxLive or our community Youtube page.

For the makers looking to get started, you can sign up for a free account, and get instant access to learning with our Academy.

Interested in getting more involved with our community? You can join us in our Slack community channel or for those who want to be more involved, look into joining one of our Meetups.

--

--

Heena S
Mendix Community

Software Engineer (Mendix Intermediate Developer) @ Indium Software with extensive experience in Java programming and Mendix Application Development.