Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

OperationDescription
createLikeCreates a like.
getLikes
Get likes for an object
Retrieves a list of users who have liked a resource.
deleteLikeDeletes a like.

Operation details

This section provides details on each of the operations.

Anchor
createLike
createLike
Creating a like

This method allows you to create The createLike operation creates a like . It could be for either a video, postspost, status, note, photo, album and or comment.

Code Block
languagehtml/xml
titlecreateLike
<facebook.createLike>
	<resourceId>{$ctx:resourceId}</resourceId>
</facebook.createLike>
Properties
  • resourceId:

    This is the ID of the resource such as a post, video, etc.

    The ID of the resource for which you want to create a like.

Anchor
request
request
Sample request

Following is a sample REST request for the createLike method that can be handled by the createLike operation

Code Block
languagehtml/xml
titleSample Request for createLike
{
"apiUrl":"https://graph.facebook.com",
"apiVersion":"v2.4",
"accessToken":"CAAD8biEgxBIBAOt0XA4FdFFQXg8hzVtYHdrDpeeRa1nHmCylWoOiFmZAWmDYMXnZCZC2akkuIsIM2tEXZBZC1JbhFFZAqRZBRKKvTZCfnhSpojHW0BG3nVKBOGYJCKEcNT7T6onY2poZBrZBZB0FtgZB89ZCSr2THH48eZC5xcNcTjU0QxKZAjJj8cQjebmzm8883RhbErPEF5OcLUpdwZDZD",
"resourceId":"1402049403394184"
} 

Anchor
getLikes
getLikes

...

Retrieving likes

The getLikes operation retrieves a list of users who have liked a particular resource such as a video, post, status, note, photo, album and or comment.

Code Block
titlegetLikes
<facebook.getLikes>
	<resourceId>{$ctx:resourceId}</resourceId>
	<fields>{$ctx:fields}</fields>
	<summary>{$ctx:summary}</summary>
</facebook.getLikes>
Properties
  • resourceId: This is the The ID of the resource for which you want to retrieve likes.

  • fields: Fields to retrieve(total count) The fields to include in the response when retrieving likes.

  • summary: Set this to true, if you want to retrieve total count.

...

  • the total number of likes for the resource.

Sample request

Following is a sample REST request for the getLikes method that can be handled by the getLikes operation

Code Block
titleSample Request for getLikes
{
"apiUrl":"https://graph.facebook.com",
"apiVersion":"v2.4",
"accessToken":"CAAD8biEgxBIBAOt0XA4FdFFQXg8hzVtYHdrDpeeRa1nHmCylWoOiFmZAWmDYMXnZCZC2akkuIsIM2tEXZBZC1JbhFFZAqRZBRKKvTZCfnhSpojHW0BG3nVKBOGYJCKEcNT7T6onY2poZBrZBZB0FtgZB89ZCSr2THH48eZC5xcNcTjU0QxKZAjJj8cQjebmzm8883RhbErPEF5OcLUpdwZDZD",
"resourceId":"1402049403394184"
} 

Anchor
deleteLike
deleteLike
Deleting a like

This method allows you to delete The deleteLike operation deletes a like from a specified resource.

Code Block
languagehtml/xml
titledeleteLike
<facebook.deleteLike>
	<resourceId>{$ctx:resourceId}</resourceId>
</facebook.deleteLike> 
Properties
  • resourceId:

    This is the ID of the resource such as a post, video, etc.

    The ID of the resource.

Sample request

Following is a sample REST request for the deleteLike methodthat can be handled by the deleteLike operation.

Code Block
languagehtml/xml
titleSample Request for deleteLike
{
"apiUrl":"https://graph.facebook.com",
"apiVersion":"v2.4",
"accessToken":"CAAD8biEgxBIBAOt0XA4FdFFQXg8hzVtYHdrDpeeRa1nHmCylWoOiFmZAWmDYMXnZCZC2akkuIsIM2tEXZBZC1JbhFFZAqRZBRKKvTZCfnhSpojHW0BG3nVKBOGYJCKEcNT7T6onY2poZBrZBZB0FtgZB89ZCSr2THH48eZC5xcNcTjU0QxKZAjJj8cQjebmzm8883RhbErPEF5OcLUpdwZDZD",
"resourceId":"1402049403394184"
} 

...

Following is a sample proxy service that illustrates how to connect to Facebook with the init operation the init operation, and then use the createLike operation. The sample request for this proxy can be found in createLike sample request. You can use this sample as a template for using other operations in this category.

Info

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

Code Block
languagehtml/xml
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="facebook_createLike"
       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="resourceId" expression="json-eval($.resourceId)"/>
         <facebook.init>
            <apiUrl>{$ctx:apiUrl}</apiUrl>
			<apiVersion>{$ctx:apiVersion}</apiVersion>
            <accessToken>{$ctx:accessToken}</accessToken>
         </facebook.init>
         <facebook.createLike>
            <resourceId>{$ctx:resourceId}</resourceId>
         </facebook.createLike>
         <respond/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>