Overview
The following operations allow you to work with likes. Click an operation name to see details on how to use it.
For a sample proxy service that illustrates how to work with likes, see Sample configuration.
Operation | Description |
---|---|
createLike | Creates a like. |
getLikes | Get likes for an object. |
deleteLike | Deletes a like. |
Operation details
This section provides details on each of the operations.
Creating a like
This method allows you to create a like. It could be for a video, posts, status, note, photo, album and comment.
<facebook.createLike> <resourceId>{$ctx:resourceId}</resourceId> </facebook.createLike>
Properties
resourceId: This is the ID of the resource such as a post, video, etc.
Sample request
Following is a sample REST request for the createLike method.
{ "apiUrl":"https://graph.facebook.com", "apiVersion":"v2.4", "accessToken":"CAAD8biEgxBIBAOt0XA4FdFFQXg8hzVtYHdrDpeeRa1nHmCylWoOiFmZAWmDYMXnZCZC2akkuIsIM2tEXZBZC1JbhFFZAqRZBRKKvTZCfnhSpojHW0BG3nVKBOGYJCKEcNT7T6onY2poZBrZBZB0FtgZB89ZCSr2THH48eZC5xcNcTjU0QxKZAjJj8cQjebmzm8883RhbErPEF5OcLUpdwZDZD", "resourceId":"1402049403394184" }
Get likes
This method allows you to get likes for an object such as video, posts, status, note, photo, album and comment.
<facebook.getLikes> <resourceId>{$ctx:resourceId}</resourceId> <summary>{$ctx:summary}</summary> </facebook.getLikes>
Properties
resourceId
: This is the ID of the resource.fields: Fields to retrieve(total count).
summary
: Set true, to retrieve total count.
Sample request
Following is a sample REST request for the getLikes
method.
{ "apiUrl":"https://graph.facebook.com", "apiVersion":"v2.4", "accessToken":"CAAD8biEgxBIBAOt0XA4FdFFQXg8hzVtYHdrDpeeRa1nHmCylWoOiFmZAWmDYMXnZCZC2akkuIsIM2tEXZBZC1JbhFFZAqRZBRKKvTZCfnhSpojHW0BG3nVKBOGYJCKEcNT7T6onY2poZBrZBZB0FtgZB89ZCSr2THH48eZC5xcNcTjU0QxKZAjJj8cQjebmzm8883RhbErPEF5OcLUpdwZDZD", "resourceId":"1402049403394184" }
Deleting a like
This method allows you to delete a like.
<facebook.deleteLike> <resourceId>{$ctx:resourceId}</resourceId> </facebook.deleteLike>
Properties
resourceId: This is the ID of the resource such as a post, video, etc.
Sample request
Following is a sample REST request for the deleteLike method.
{ "apiUrl":"https://graph.facebook.com", "apiVersion":"v2.4", "accessToken":"CAAD8biEgxBIBAOt0XA4FdFFQXg8hzVtYHdrDpeeRa1nHmCylWoOiFmZAWmDYMXnZCZC2akkuIsIM2tEXZBZC1JbhFFZAqRZBRKKvTZCfnhSpojHW0BG3nVKBOGYJCKEcNT7T6onY2poZBrZBZB0FtgZB89ZCSr2THH48eZC5xcNcTjU0QxKZAjJj8cQjebmzm8883RhbErPEF5OcLUpdwZDZD", "resourceId":"1402049403394184" }
Sample configuration
Following is a sample proxy service that illustrates how to connect to Facebook with the init operation and use createLike. 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.
As a best practice, create a separate sequence for handling the response payload for errors. In the following sample, this sequence is "faultHandlerSeq".
<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>