Post new comment to a Status via API

2019-04-02 09:58发布

I'm having a status_id and try to post a new comment to:

POST https://graph.facebook.com/STATUS_ID/comments {message: "text" }

I get the result

{
 "error": {
   "message": "(#200) Cannot access object_id: 10150593515092107", 
   "type": "OAuthException", 
   "code": 200
  }
}

I can do the same POST for /likes and it works.

If I add a comment to a Photo it also works. I can then use the object_id of a photo but no such field exists on a status.

2条回答
爷的心禁止访问
2楼-- · 2019-04-02 10:10

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.

查看更多
再贱就再见
3楼-- · 2019-04-02 10:22

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

查看更多
登录 后发表回答