Post new comment to a Status via API

我与影子孤独终老i 提交于 2019-12-03 21:26:59
arseny

After two days of struggle i found the answer, at least for regular posts.

Every object_id of a post on facebook consists from two parts: [author id]_[post id] you can see it clearly in the permalink: https://www.facebook.com/permalink.php?story_fbid=[post id]&id=[author id]

so when you use the full id it seems to work!

Now the real question is why isn't it propertly documented by facebook?!? and to who can I write an angry letter for wasting my time.

it still doesn't work for videos or photos for example because I don't know what is the proper ID's for them and it isn't written anywhere. So if you succeed please let me know.

here is a practical solution I use knowing that for some objects the userid is needed and for some it is not (for comments and likes).

    var message = 'WHATEVER MESSAGE';

FB.api('/'+object_id+'/comments','post',{
    message:message
},function(r){
    if (!r || r.error) {
        // if it fails,send it back with the fbid on it
        FB.api('/'+fbme.id+'_'+object_id+'/comments','post',{
            message:message
        },function(r){
            if (!r || r.error) {
                //  if it fails again send back to server side for failure recording 
                $.post("actions.php",{
                    req:'badPost',
                    oid:object_id
                },function(n){

                });

            }
        });             
    } 
});

this works for me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!