How to get the image from a facebook photo comment

2019-09-14 01:58发布

问题:

Either API or FQL, I am trying to get the photo submitted as comment in a photo post.

To make clearer here is what I am saying

  • I post a photo on my page timeline.
  • people now post comments on the said photo
  • either text comment or attaching photo in each comment.

Now, what I am getting is the comment information only. I want to get the information about the photo used in comment also.

Thanks.

回答1:

The picture (in the comment) could be fetched with the attachment parameter.

By default, you did not get the attachment field in the result, so you have to write this field explicitly. just like this -

me/posts?fields=comments.message,comments.id,comments.attachment

Demo

Ref: Comments



回答2:

This is the same for page comments as I just discovered:

/{page-post-id}/comments?fields=from,message,id,attachment,created_time,comments.fields(from,message,id,attachment,created_time)

this will return all replies (and replies to those replies) for a particular page post. if there is an image on a reply it will be under 'attachment'

result is a bit like this:

Array
(
    [data] => Array
        (
            [0] => Array
                (
                    [from] => Array
                        (
                            [name] => ***********
                            [id] => ***********
                        )

                    [message] => test reply with a picture
                    [id] => ***********
                    [attachment] => Array
                        (
                            [type] => photo
                            [target] => Array
                                (
                                    [id] => ***********
                                    [url] => ***********
                                )

                            [url] => ***********
                            [media] => Array
                                (
                                    [image] => Array
                                        (
                                            [height] => 540
                                            [src] => ***********
                                            [width] => 720
                                        )

                                )

                        )

                    [created_time] => 2014-03-29T11:59:53+0000
                )

            [1] => Array
                (
                    [from] => Array
                        (
                            [name] => ***********
                            [id] => ***********
                        )

                    [message] => ***********
                    [id] => ***********
                    [created_time] => 2014-03-29T11:55:09+0000
                )

            [2] => Array
                (
                    [from] => Array
                        (
                            [name] => ***********
                            [id] => ***********
                        )

                    [message] => ***********
                    [id] => ***********
                    [created_time] => 2014-03-29T11:16:45+0000
                    [comments] => Array
                        (
                            [data] => Array
                                (
                                    [0] => Array
                                        (
                                            [from] => Array
                                                (
                                                    [name] => ***********
                                                    [id] => ***********
                                                )

                                            [message] => ***********
                                            [id] => ***********
                                            [created_time] => 2014-03-29T11:18:07+0000
                                        )

                                    [1] => Array
                                        (
                                            [from] => Array
                                                (
                                                    [name] => ***********
                                                    [id] => ***********
                                                )

                                            [message] => ************
                                            [id] => ***********
                                            [created_time] => 2014-03-29T11:18:48+0000
                                        )