开发者

How to build FaceBook "Like Button" that likes a Page message?

开发者 https://www.devze.com 2023-03-07 17:27 出处:网络
For example: I have a FaceBook Page about my website. On my website, I display my 3 most recent FaceBook page messages (graph.facebook开发者_运维问答.com/[pageId]/[more parameters])

For example:

  • I have a FaceBook Page about my website.

  • On my website, I display my 3 most recent FaceBook page messages (graph.facebook开发者_运维问答.com/[pageId]/[more parameters])

  • Next to each FaceBook Page message (as they appear on my website) I would like to add a FaceBook Like button. When the like button is clicked, a "Like" should be given to the FaceBook Page Message. How can this be done?


Simply use the permalink of the post as your url in an fb:like button. The tricky part will be figuring out what the permalink is, since it takes different forms if it's a link, status, or video. For a link or status update, it's this format:

http://www.facebook.com/<PAGE_USERNAME>/posts/<POST_ID> 

Or, if you don't have a username:

http://www.facebook.com/permalink.php?story_fbid=<POST_ID>&id=<PAGE_ID>

You can determine the post ID and page ID by accessing http://graph.facebook.com/<PAGE_ID>/posts and splitting the id string on the _.


You should be able to POST to the /likes URL of any object that supports likes. No arguments should be specified. You can remove a like by executing a DELETE request to the same URL.

/OBJECT_ID/likes
Like the given object (if it has a /likes connection)

So the URL you should POST to, is https://graph.facebook.com/[pageId]/likes

Read more under Publishing on this page: http://developers.facebook.com/docs/reference/api/

0

精彩评论

暂无评论...
验证码 换一张
取 消