...
For a sample proxy service that illustrates how to work with likes, see Sample configuration.
Get likes for an objectRetrieves a list of users who have liked a resource. |
deleteLike | Deletes a like. |
Operation details
This section provides details on each of the operations.
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 |
---|
language | html/xml |
---|
title | createLike |
---|
|
<facebook.createLike>
<resourceId>{$ctx:resourceId}</resourceId>
</facebook.createLike> |
Properties
Sample request
Following is a sample REST request for the createLike method that can be handled by the createLike
operation.
Code Block |
---|
language | html/xml |
---|
title | Sample Request for createLike |
---|
|
{
"apiUrl":"https://graph.facebook.com",
"apiVersion":"v2.4",
"accessToken":"CAAD8biEgxBIBAOt0XA4FdFFQXg8hzVtYHdrDpeeRa1nHmCylWoOiFmZAWmDYMXnZCZC2akkuIsIM2tEXZBZC1JbhFFZAqRZBRKKvTZCfnhSpojHW0BG3nVKBOGYJCKEcNT7T6onY2poZBrZBZB0FtgZB89ZCSr2THH48eZC5xcNcTjU0QxKZAjJj8cQjebmzm8883RhbErPEF5OcLUpdwZDZD",
"resourceId":"1402049403394184"
} |
...
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 |
---|
language | html/xml |
---|
|
<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 countthe 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 |
---|
title | Sample Request for getLikes |
---|
|
{
"apiUrl":"https://graph.facebook.com",
"apiVersion":"v2.4",
"accessToken":"CAAD8biEgxBIBAOt0XA4FdFFQXg8hzVtYHdrDpeeRa1nHmCylWoOiFmZAWmDYMXnZCZC2akkuIsIM2tEXZBZC1JbhFFZAqRZBRKKvTZCfnhSpojHW0BG3nVKBOGYJCKEcNT7T6onY2poZBrZBZB0FtgZB89ZCSr2THH48eZC5xcNcTjU0QxKZAjJj8cQjebmzm8883RhbErPEF5OcLUpdwZDZD",
"resourceId":"1402049403394184"
} |
Deleting a like
This method allows you to delete The deleteLike
operation deletes a like from a specified resource.
Code Block |
---|
language | html/xml |
---|
title | deleteLike |
---|
|
<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 |
---|
language | html/xml |
---|
title | Sample 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 |
---|
|
<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> |