13

When I use the Graph API to fetch a comment containing an image, the returned JSON contains no reference to it, e.g.

{
  "id": "10151452996201039_9302037", 
  "from": {
    "name": "Anton Raxacoricofallapatorius Dyudin", 
    "id": "1534947411"
  }, 
  "message": "", 
  "can_remove": true, 
  "created_time": "2013-06-20T06:47:41+0000", 
  "like_count": 0, 
  "user_likes": false
}

I am likewise lost as to what POST field can be used to embed a picture when commenting. How can I achieve either of the above?

ekad
  • 14,436
  • 26
  • 44
  • 46
Anton
  • 133
  • 1
  • 6
  • I also want to post photo comments through FB API but am lost. I don't think there's any way yet in the API to get or post them. – DivinesLight Dec 03 '13 at 08:07

3 Answers3

10

Add fields=attachment to your query.

https://developers.facebook.com/docs/graph-api/reference/comment

LukasFT
  • 164
  • 2
  • 10
Elben Shira
  • 2,086
  • 3
  • 14
  • 13
  • 1
    This would appear to be the case, however the API explorer grays out the choice with no explanation, and attempting the URL directly yields an "Unsupported get request" exception. – Anton Aug 03 '13 at 00:47
  • 1
    Graph api response does not seem to give the attachment field. Also the FQL query gives null for the field attachment. Any luck @Anton? – digitalPBK Sep 07 '13 at 06:41
  • I have observed the same phenomenon: the field is null both through the FQL and the graph API, as well as in the graph explorer. Any idea anyone ? – mathieu Nov 12 '13 at 17:22
  • Worked for me, too. Should be the accepted answer for anyone looking to get attachment data with their graph request. – Mikael Kessler Apr 21 '14 at 04:15
  • I'm trying to get the feed comments. How to mention field parameter in me/feed api? – Foreever May 22 '14 at 06:52
3

It actually works when you use fields=attachment

https://graph.facebook.com/POSTID_COMMENTID?fields=attachment&access_token=ACCESS_TOKEN
Ahsaan Yousuf
  • 685
  • 7
  • 16
1

If you want a more extensive query that return everythings and I mean everything including user id's, profile image (large version), comment related info as well and attachement info use this.

&fields=id,status_type,created_time,from{name,id,picture.width(400).height(400)},message,picture.width(400).height(400),link,icon,comments{comments{attachment,from{picture.width(400).height(400),name},id,message,created_time},from{picture.width(400).height(400),name},id,message,attachment,created_time}
Cesar Bielich
  • 4,754
  • 9
  • 39
  • 81