Like Action

Like is one of the most populars actions on Facebook today and is available as a standard Open Graph action.

Developers can design how like fits into the core user experience of any Open Graph-integrated app, through building a custom in-app “like button” that works across any mobile and web platform, helping to improve in-app content relevance while enjoying additional distribution on Facebook.

The og.likes action can refer to any open graph object or URL, except for Facebook Pages or Photos.

This action and associated object types are automatically added to the App Dashboard when you use the action for the first time.

This document covers the following topics:

Code Samples

You can find platform-specific code samples on how to create, read, update, or delete an og.likes action in the API Reference Guide.

Publishing Likes

An app can publish a like action, on behalf of the user, as long as the following conditions are true:

  1. The viewer of the in-app content is a Facebook user who has Facebook-authed and granted the app publish_actions permission
  2. The in-app content has an Open Graph object page that is properly marked-up using Open Graph metatags
  3. The viewer has intentionally clicked on a custom in-app “like button” associated with the in-app content

Here, developers should design their apps to provide an in-app “like button” that could be clicked on. This in-app "like button" should use a developer's custom app branding instead of Facebook branding, and follow our branding guidelines. Apps with existing custom in-app “like buttons” can now benefit from additional distribution on Facebook when these buttons publish built-in Like action stories to Open Graph.

A successful publish of a built-in Like action will appear as an Open Graph story in all places that other Open Graph action stories appear (Ticker, News Feed, Timeline, Activity Log).

To start configuring an app to have the ability to publish a built-in Like action on an Open Graph object:

  • Your app needs to publish one og.likes action. Once that's done, the og.likes action will show up in the Review Status of your app's dashboard.
  • Create a custom in-app “like button” associated with each Open Graph object that users can “like”.
  • When a user clicks on this button and has both FB-authed and provided the publish_actions permission to an app in the past, the app should publish a built-in Like action story on the Open Graph object.

The usage of the built-in Like action by an app, as with any Open Graph action, needs to be submitted and approved. For Facebook Pages or websites that do not integrate with Facebook Authentication, developers should continue to use the Like button social plugin.

To publish a built-in Like action on an Open Graph object, invoke the following HTTP POST request with a user’s access token and the url of the Open Graph object. This Open Graph object can be of any type.

curl -X POST \
  -F 'access_token=USER_ACCESS_TOKEN' \
  -F 'object=OG_OBJECT_URL' \
  https://graph.facebook.com/[User FB ID]/og.likes

which in turn will return the ID of the built-in Like action instance if the call is successful

{ "id":"396528780387583" }

Note that trying to re-publish a built-in Like action on an Open Graph object that has already been “liked” by the user in the past will result in the following error

{
  "error": {
    "message": "(#3501) User is already associated to the object with the Like action type. Original Action ID: 396497300390731",
    "type": "OAuthException",
    "code": 3501
  }
}

A re-publish will however succeed if the last known successful built-in Like action instance by the user on the object was removed. To undo a published “Like” action, essentially emulating an “Unlike”, invoke the following HTTP DELETE call on the ID of a Like action instance that was returned from a successful publish

curl -X DELETE \
  -F 'access_token=USER_ACCESS_TOKEN' \
  https://graph.facebook.com/[Like Action Instance ID]

Notifications for Likes

An app can enable notifications for creators of custom objects that receive in-app likes. This is called a Subscribe Action (formerly Creation Action). You can learn more about subscription actions in our custom object types document.

Submission Requirements

When creating a built-in like Open Graph action please provide clear, consistent experiences for your users by adhering to the following criteria:

Branding

Your built-in Like button should not emulate or otherwise copy the design of Facebook’s Like buttons. For example, you should not use a “thumbs up” image within your Open Graph actions, and any Like button you create should not confuse users into thinking that your Open Graph action will result in a connection to a Facebook Page. Please create a unique graphic for your Open Graph action that reflects your own branding and the user experience of your site.

DO:

DON’T:

Clear Indication

A Like may only be published when a person performs a like action. For example, if someone gives a movie a five-star rating in a movie app, that warrants a rated action rather than a like action.