How to get the image from a facebook photo comment?

我怕爱的太早我们不能终老 提交于 2019-12-12 01:23:40

问题


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
                                        )



来源:https://stackoverflow.com/questions/19156246/how-to-get-the-image-from-a-facebook-photo-comment

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