I'm developing a Facebook application that retrieves specific facebook wall posts. I simply want to allow the user to "like" the post from within my application using the javascript sdk. Anyone know how to accomplish this?
Like a Facebook Wall Post - Javascript
Asked Answered
UPDATE:
Issuing a POST
request to the likes
connection of the post object is all you need:
You can like a Post by issuing a HTTP POST request to the
POST_ID/likes
connection with thepublish_stream
permission. No parameters necessary.
Example:
FB.api("/POST_ID/likes", 'post',function(response) {
if(response === true) {
alert("done!");
}
});
The above request should return true
on success.
Thanks you very much. I really wish Facebook would put some of their billions into better documentation. –
Florentinaflorentine
nevermind. I deleted the comment. However, as a follow-up, What would be the best way to determine whether or not a user already likes a particular post. I thought about returning all the likes for a particular post, looping through the values and testing each one against the user's id, but that doesn't seem like an efficient solution. –
Florentinaflorentine
@rollsRLS8822: how about asking a new question for that? :-) –
Kith
Do you need a special permission for this? –
Breann
@Prabhu: Yes,
publish_stream
:Enables your application to post content, comments, and **likes** to a user's stream and to the streams of the user's friends.
–
Kith © 2022 - 2024 — McMap. All rights reserved.