4
votes

I'm working currently on messenger bot which will perform like and share action on fb posts.

My question is: Does Facebook allows application to like and share posts for user via Graph API?

I found some Open Graph documentation about og.likes, but I don't know if it's deprecated or not. (link: https://developers.facebook.com/docs/opengraph/guides/og.likes/). I've made some sample requests and created open graph object of like, but post isn't liked. I didn't see any action on my account.

Request that was made:

fb.api('me/og.likes', 'post',
    {object: https://www.facebook.com/permalink.php?story_fbid=55431741576&id=38441731099'}, ...);

Object that was created:

{ end_time: '2016-06-17T07:14:48+0000',
  start_time: '2016-06-17T07:14:48+0000',
  type: 'og.likes',
  application: 
   { category: 'Utilities',
     link: 'https://apps.facebook.com/messenger-bot/',
     name: 'Test1',
     namespace: 'messenger-bot',
     id: '173992418' },
  comments: 
   { data: [],
     can_comment: true,
     comment_order: 'chronological',
     count: 0 },
  from: { name: 'Bartłomiej Pasik', id: '122387551' },
  likes: { data: [], can_like: true, count: 0, user_likes: false },
  no_feed_story: false,
  publish_time: '2016-06-17T07:14:48+0000',
  data: 
   { object: 
      { id: '95990823123',
        type: 'website',
        url: 'https://www.facebook.com/permalink.php?story_fbid=55431741576&id=38441731099' } },
  id: '1210344228' }
3

3 Answers

1
votes

Ok, I found answer here: https://developers.facebook.com/docs/graph-api/reference/v2.6/object/likes

Permission publish_action is needed.

1
votes

According to the docs you can like an object (post, photo, etc) only if you are using a page access token. This appears to be new behavior as of November 17, 2016.

0
votes

On the link referenced in the question it appears that there is a reference to publish_actions within the 'Publishing Likes' section.

For reference the documentation states the following applicable to apps:

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

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