This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Working with Messages in Facebook



Overview

The following operation allows you to work with messages. Click the operation name to see details on how to use it. 

For a sample proxy service that illustrates how to work with messages, see Sample configuration.

OperationDescription
getMessageRetrieves a message.

Operation details

This section provides details on the operation.

Retrieving a message

The getMessag operation retrieves a message based on the specified message ID.

Note

Before performing this operation, ensure that you call the init operation with the fields properties.

getMessage
<facebook.getMessage>
	<messageId>{$ctx:messageId}</messageId>
    <fields>{$ctx:fields}</fields>
</facebook.getMessage> 
Properties

Sample request

Following is a sample REST request that can be handled by the getMessage operation. 

Sample Request for getMessage
{
"apiUrl":"https://graph.facebook.com",
"apiVersion":"v2.4",
"accessToken":"CAACEdEose0cBAGlDzIRGv0KAopxqBhmSKgQTbfvnROAZAwZBPSnH7OpqVeEP9t4eZCpO2xbIdIZAI4g6MayNwIgk3R7t4xqX2atZAKfxqJS8UnacJJjthuAsnr8eI7pyOuLojRtdzH2zNFdwt7K1QeJgH6isCYpAFg2ZBY6r3MqDssgTQ7fES5zCrPpopr3S29wAKiz089MgZDZD",
"messageId":"192451917539863",
} 

Related Facebook documentation

https://developers.facebook.com/docs/graph-api/reference/message#read

Sample configuration

Following is a sample proxy service that illustrates how to connect to Facebook with the init operation,  and then use the getMessage operation. The sample request for this proxy can be found in getMessage sample request

As a best practice, create a separate sequence to handle response payload errors. In the following sample, the sequence that handles errors is the faultHandlerSeq.

Sample Proxy
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="facebook_getMessage"
	   transports="https,http"
	   statistics="disable"
	   trace="disable"
	   startOnLoad="true">
  <target>
    <inSequence onError="faultHandlerSeq">
      <property name="apiUrl" expression="json-eval($.apiUrl)"/>
	  <property name="apiVersion"   expression="json-eval($.apiVersion)"/>
      <property name="accessToken" expression="json-eval($.accessToken)"/>
	  <property name="fields" expression="json-eval($.fields)"/>
      <property name="messageId" expression="json-eval($.messageId)"/>
      <facebook.init>
		<apiUrl>{$ctx:apiUrl}</apiUrl>
        <apiVersion>{$ctx:apiVersion}</apiVersion>
		<accessToken>{$ctx:accessToken}</accessToken>
	  </facebook.init>
      <facebook.getMessage>
        <messageId>{$ctx:messageId}</messageId>
		<fields>{$ctx:fields}</fields>
      </facebook.getMessage>
	  <respond/>
    </inSequence>
    <outSequence>
      <property name="messageType" value="application/json" scope="axis2" />
      <send/>
    </outSequence>
  </target>
</proxy>