Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

This content has been archived and is no longer being updated.

Links may not function; however, this content may be relevant to outdated versions of the product.

How to post updates to Facebook from Pega Platform

Updated on December 18, 2017

Facebook is a highly-popular social networking site. What began as a limited exercise for Harvard undergraduates who wanted to connect or find out about others on campus has become a hub where hundreds of millions of people post daily updates, play games, and get a sense of what is exciting and interesting in the world.

Having a dynamic Facebook presence is becoming essential for companies that want to present as dynamic and connected. You can post updates directly to your Facebook presence from a PRPC V 6.2 or newer application, broadcasting company milestones, job opportunities (you could even include a SnapStart URL which, when clicked, would open a job-application flow in your application), or other matters of interest.

a Facebook message

Suggested Approach

You have to complete several tasks before you can start sending updates from your PRPC application to Facebook. Some tasks are on the Facebook side of the process; some are within PRPC.

At a high level:

There is a further step that is beyond the scope of this article: gathering an audience to read the updates you post. This is a critical step that makes all the rest of your efforts on this project worthwhile. Some links at the end of the article lead to popular online articles on how to build up your Facebook presence.

Facebook side

There are two steps to establishing yourself on Facebook: creating an account and creating an application related to the account. The application is where your updates appear. The application provides a key that you send along with each posting, so the Facebook application knows to accept it.

You as an individual may already have a presence on Facebook, and there is no reason not to use your existing account while experimenting. However, your corporate Facebook presence should have its own account before you starting posting company-related updates "for real"..

Establish a presence on Facebook

Creating a Facebook account is free. When your account exists, log in to it and, at the extreme bottom right of the screen, locate and click the Developers link:

developers link

Your Developers area appears. At the top right, locate and click the Apps link:

Apps link

On the screen that appears, click + Create New App: new app button.

If this is a new account, you may have to go through a one-time Facebook verification process at this point.

When the account is verified, the Create New App form appears:

create new app form

Provide a reasonable name for the application in the App Name field. The other options here are beyond the scope of this article. Click Continue.

back to top

Obtain an authentication token

There are many features and options available for your new application on the screen that appears. Describing them all is beyond the scope of this article. The key elements appear near the top of the display (distorted in this image):

app secret key

The App ID lets the connector connect to the correct Facebook application. The App Secret key verifies that the message is sent by a trusted source. Copy them into a text file for later use.

Assemble a URL in the following structure, replacing the bolded text with the App ID for your application:

https://graph.facebook.com/oauth/authorize?client_id=APPID&scope=offline_access,read_stream&redirect_uri=http://www.facebook.com/connect/login_success.html

Copy the URL and paste it in the location field of a browser window. The following permission screen appears, and you may have to log in to Facebook with the account you created for this purpose if you are not already logged in:

permission screen

Click Allow to let your PRPC application access your Facebook account data and post updates to the account's news feed. The browser displays a screen with the message "Success".

Before you close the browser, copy the page's URL and paste it into a text file The URL contains important information you need when configuring your PRPC application. The URL is in this form:

http://www.facebook.com/connect/login_success.html?code=
7YaBbdlAXbh2ybD03pwLde4mNaTuuA23mofmlfiDUBE.eyJpdiI6InBnODdXT
mxJUUw3ck5lV25IWFRWY1EifQ.OAxPv8JgwsBcMQM0z-TahtH6mXEjwQ5jxFJKQ7gsMEfDo5MuSS-mr_lQIA7yIwXLMPrJOd5qK_RMTtu5gqpxMJjJk3AJK1Z3QVXXXXXXXXXX

Use the string following code to assemble a new URL in the following pattern:

https://graph.facebook.com/oauth/access_token?
client_id=APP_ID
&redirect_uri=http://www.facebook.com/connect/login_success.html&
client_secret=APP_SECRET&code=CODE_FROM

APP_ID and APP_SECRET are the key strings you received when you created your Facebook application's ID, and CODE_FROM is the string following code in the previous code block.

Paste the URL in a browser window, and the resulting screen displays the access token for your Facebook profile and application:

access token

Copy the access token into a text file and save it for later use.

back to top

PRPC side

You can use an existing PRPC application, or create a new one if an existing application is not available. Log in to the application using credentials for an operator with developer privileges.

Establish a connection from your application to your Facebook presence

To establish a connection from PRPC to Facebook, first create four text properties to hold strings the connector requires. Save them in the class where you intend to create the connector rule. The four properties are:

  • FB_Callback
  • FB_Message
  • FB_Target_ID
  • FB_Access_token

Create a Connect-HTTP rule. In this example its name is PostMessageFacebook.

On the Service tab provide the following information:

  • HTTP Method - GET
  • HTTP Version - 1.1
  • Response Timeout - 30000
  • Status Value - .pyStatusValue
  • Status Message Property - .pyStatusMessage
  • Error Handler Flow - ConnectionProblem

service tab

On the Request tab provide the query string parameters:

NameDescriptionMap FromMap From Key
callbackcallbackClipboardFB_Callback
messagemessageClipboardFB_Message
target_idtarget_idClipboardFB_Target_ID
access_tokenaccess_tokenClipboardFB_Access_Token

request tab

Create an activity to post an update to the Facebook account. In this example its name is PostMessageToFacebook:

activity to send update to Facebook

On the Steps tab:

  1. In Step 1 use the Property-Setmethod. You can set the access token in several ways. In this example we use a static value:
    PropertyNamePropertyValue
    .FB_Access_Token[The access token you created using Facebook URLs and saved to a text file]
    .FB_Callback"XML"
  2. In Step 2 use the Connect-HTTPmethod. Set the parameters:
    ParameterValue
    ServiceNamePostMessageFacebook (the connect rule you created earlier)
    ExecutionModeRun
    EndPointURLhttps://api.facebook.com/method/stream.publish

back to top

Create a process where you can write and send updates

Create a section with a field for the Facebook ID to use and the message to send. In this example the section's name is Facebook. Use the properties FB_Target_ID and FB_Message for the input fields:

create section

You can insert sending a Facebook update into an existing flow, or include it in its own subflow. This exercise uses a simple flow, SendMessageFacebook:

flow to call activity

At runtime, the flow creates a work item and puts it in the user's worklist. The item has one action option, to send a message to Facebook. The flow action displays the section you created.

section where you compose the Facebook update

Enter the Facebook ID for the account with the application you created, add a message, and click Submit. The message appears in the Facebook account's status update stream:

Facebook update

back to top

Additional Information

How to create SnapStart URLs for desktop integration
Tutorial: Introduction to Application Integration
Connecting to LinkedIn from PRPC
Connecting to Twitter from PRPC

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us