Q:

How to use the parameter 'attachment_id' in FB.api('OPEN_GRAPH_ID/comments', 'post')?

From the error message of FB.api('OPEN_GRAPH_ID/comments', 'post', ...)
"(#100) Requires one of the params: attachment_id,message"

(Here is a screenshot of my code and the error message)
I've found that 'attachment_id' can be a parameter of a comment action.
However, the usage of attachment_id seems isn't mentioned on API Document: Comments
then, I tried to use the published photo's fbid as the attachment_id...
I got another error message
"You cannot publish already published photos."

So...
I was confused about this parameter...
if I didn't publish a media resource before, can I get the fbid of this resource?
or the parameter 'attachment_id' is not used as comments post?
In fact... I would like to know if there is any way to comment a open graph object with a photo via Facebook JavaScript SDK...
This feature is announced in last days.
Thanks for your help!!

A:

Actually you can use attachments in comments, but I can't figure out how to detect pages where this feature is enabled.
First of all you need to upload a photo to the user album with "no_story" parameter set to true,
save photo object_id and pass it to the comment:
Pseudo code:
//upload photo
FB.api(me/photos, 'POST', {source...}, function(result) { 
    var comment = {
      "message" : "hey, ok",
      "attachment_id" : result.id
    };
    FB.api(result.id + '/comments', 'POST', comment, function(result) {
       //comment result
    });
});

On some pages this doesn't work, I guess this is due some privacy settings, but can't figure out how to detect pages with attachment disabled... 
Vote on bug, please: https://developers.facebook.com/x/bugs/406219529521415/

