如何从Facebook照片评论中获取图像?

时间:2013-10-03 10:00:33

标签: facebook facebook-graph-api facebook-fql facebook-comments

无论是API还是FQL,我都试图将照片作为评论提交到照片中。

在这里说清楚是我在说什么

  • 我在我的页面时间轴上发布了一张照片。
  • 人们现在对上述照片发表评论
  • 每条评论中的文字评论或附加照片。

现在,我得到的只是评论信息。 我想获得有关评论中使用的照片的信息。

感谢。

2 个答案:

答案 0 :(得分:2)

可以使用attachment参数获取图片(在评论中)。

默认情况下,您没有在结果中获得附件字段,因此您必须明确地写入此字段。就像这样 -

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

Demo

参考:Comments

答案 1 :(得分:0)

这与我刚刚发现的页面评论相同:

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

这将返回特定页面帖子的所有回复(以及对这些回复的回复)。如果回复中有图片,则会在“附件”下

结果有点像这样:

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
                                        )