FB.api('/'+post_id_here+'/comments', 'POST',{ access_token: token, message: jQuery.trim(jQuery("#msfb-commentbox").val()) }, function(response) {
if (!response || response.error) {
alert("Errors - you are not permitted to comment on that post");
} else {
//post success
location.reload(true);
}
});
here you have to enter post id at first and enter the user entered
comment as value of message paramenter.Also you will
need access token of the user who commenting.you can get token by
javascript sdk FB.login call which i used in one of my post on how
to post to facebook wall by graph api.
following are codes for like.not much difference with above codes -
FB.api('/'+post_id_here+'/likes?access_token='+token+'', 'POST',function(response) {
if (!response || response.error) {
alert("Errors - you are not allowed to like the post");
} else {
//sucess
location.reload(true);
}
});
hope that helps very much.Don't forget to like and share it.