The Notification Worker can be used to post content to Twitter or Facebook.
Worker Configuration
Property | Type | Description |
---|---|---|
notifiers | Array, required | An array of objects. Each contains provider specific settings for Facebook or Twitter, see below |
Property | Type | Description |
---|---|---|
name | String, required | A name for this notifier. Used in postMessage(). You may like to use the same name as the page being posted to/as |
provider | String, required | Always "facebook" |
default | Boolean, required | If true will be called by postMessage() if "notify" is empty |
pageId | String, required | The ID of the Facebook page you would like to post as. This can be found in the administrator view of your page's "about" section |
extendedPageAccessToken | String, required | The access token generated by the GOSS supplied form, see below |
To post content as your Facebook page, you first need to create a Facebook App, which provides the link between your website (and iCM) and your page. Facebook Apps are linked to a Facebook Developer Account. The administrator of the Facebook App should also be an administrator for your Facebook page.
By default Facebook provides short-lived access tokens that expire after a couple of hours. For pages, Facebook provides extended Facebook Page Access Tokens. These tokens are linked to a Facebook App, which is in turn linked to a Facebook user via their Facebook Developer account. These tokens will last until:
- The app developer changes their Facebook account password
- The app developer loses admin access for the target page
- You delete or de-authorize your Facebook App
Generating these access tokens is a fairly labyrinthine process, summarised on Stack Overflow here.
To make the process easier, we have created a form (EXTENDPAGEACCESSTOKEN), which could be made available to the Facebook App Developer using an iCM form-app shortcut. The form should be used from a domain that matches the App Domain set in your Facebook App (see below). It would also be possible to publish this form into a secure area of your website.
To use this form you will need:
- Your App ID - the ID of the Facebook App that will be used to post to your page
- Your App Secret - the secret code of the Facebook App that will be used to post to your page
- Your Page ID - the ID of the Facebook page you would like to post as. This can be found in the administrator view of your page's "about" section
Add these three values to the form, press the generate button, and copy the access token into the worker configuration file.
This form only needs to be used when first generating the token, or if the token expires. Once the token has been generated, we recommend unpublishing the form.
Creating a Facebook App
This summary is correct at the time of writing (March 2017) but is obviously subject to the whims of Facebook. Their documentation can be found at Facebook App Development (opens new window)
Log into the Facebook Developer Portal (opens new window).
You will need to create a Facebook App in the "Apps for Pages" category.
The display name you create for your App will be visible as the "published by" user to other page admin users. At the time of writing it is not publicly visible.
In your App Settings you need to add your website as a registered website for the App using the "Add Platform" controls. Once your website has been added as a platform, it then needs to be added as an App Domain.
Your App ID and App secret can now be found on your App Dashboard.
Property | Type | Description |
---|---|---|
name | String, required | A name for this notifier. Used in postMessage(). You may like to use the same name as the account being posted to/as |
provider | String, required | Always "twitter" |
default | Boolean, required | If true will be called by postMessage() if "notify" is empty |
consumerKey | String, required | The key from your twitter App, see below |
consumerSecret | String, required | The key from your twitter App, see below |
accessToken | String, required | The key from your twitter App, see below |
accessTokenSecret | String, required | The key from your twitter App, see below |
To post content to a Twitter account, you first need to create a Twitter App, which provides the link between your website (and iCM) and your account.
Log into Twitter using the account you would like to post to. Create an App at https://apps.twitter.com (opens new window).
Once the App has been created, use the "Keys and Access Tokens" page to generate the required keys and tokens. Copy these into the worker configuration file.
Example Worker Configuration
{
"name": "notification",
"instances": 4,
"notifiers": [
{
"name": "tweet",
"provider": "twitter",
"default": true,
"consumerKey": "*gAJN... ...tr0G*",
"consumerSecret": "*JBDl... ...0PN3*",
"accessToken": "*2262... ...dq55*",
"accessTokenSecret": "*qClS... ...51x7*"
},
{
"name": "MyFacebookPage",
"provider": "facebook",
"default": true,
"pageId": "*testingpageId*",
"extendedPageAccessToken": "*EAAE... ...ZDZD*"
},
{
"name": "MySecondFacebookPage",
"provider": "facebook",
"default": true,
"pageId": "*testingpageId*",
"extendedPageAccessToken": "*EAAE... ...ZDZD*"
}
]
}