简体   繁体   English

喜欢通过API发布在Facebook上

[英]Like post at Facebook via API

I'm working currently on messenger bot which will perform like and share action on fb posts. 我目前正在使用messenger机器人,它将在fb帖子上表现得像并分享行动。

My question is: Does Facebook allows application to like and share posts for user via Graph API? 我的问题是: Facebook是否允许应用程序喜欢并通过Graph API分享用户的帖子?

I found some Open Graph documentation about og.likes, but I don't know if it's deprecated or not. 我找到了一些关于og.likes的Open Graph文档,但我不知道它是否已被弃用。 (link: https://developers.facebook.com/docs/opengraph/guides/og.likes/ ). (链接: 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' }

Ok, I found answer here: https://developers.facebook.com/docs/graph-api/reference/v2.6/object/likes 好的,我在这里找到答案: https//developers.facebook.com/docs/graph-api/reference/v2.6/object/likes

Permission publish_action is needed. 需要权限publish_action。

According to the docs you can like an object (post, photo, etc) only if you are using a page access token. 根据文档 ,只有在使用页面访问令牌时,您才能like对象(帖子,照片等)。 This appears to be new behavior as of November 17, 2016. 这似乎是截至2016年11月17日的新行为。

On the link referenced in the question it appears that there is a reference to publish_actions within the 'Publishing Likes' section. 在问题中引用的链接上 ,似乎在“发布喜欢”部分中引用了publish_actions

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 应用程序内容的查看者是Facebook用户,其具有Facebook-authed并被授予app publish_actions权限
  • The in-app content has an Open Graph object page that is properly marked-up using Open Graph metatags 应用内内容包含一个Open Graph对象页面,该页面使用Open Graph元标记进行了正确标记
  • The viewer has intentionally clicked on a custom in-app “like button” associated with the in-app content 观众有意点击了与应用内内容相关联的自定义应用内“按钮”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM