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/.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 17 Current »



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.

OperationDescription
createLikeCreates a like.
getLikesGet likes for an object.
deleteLikeDeletes 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.

createLike
<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. 

Sample Request for createLike
{
"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.

getLikes
<facebook.getLikes>
	<resourceId>{$ctx:resourceId}</resourceId>
	<fields>{$ctx:fields}</fields>
	<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. 

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 a like.

deleteLike
<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.

Sample Request for deleteLike
{
"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>                                 
  • No labels