Facebook的评论,评论图片

时间:2015-12-15 22:40:23

标签: facebook facebook-graph-api laravel-5

我需要了解回复评论的图片我到目前为止已经使用了这些评论来获得第一级评论的图片。

$reso = $this->getFB()->get("$id/comments?fields=likes,message,comments,from{
    likes,comments,name,picture
}", $pageToken);

这会返回图片没有问题,但仅针对第一级评论我不知道如何获得评论回复的图片?

返回当前数组

array:2 [▼
  "data" => array:13 [▼
    0 => array:4 [▼
      "message" => "OOh nice!"
      "from" => array:4 [▼
        "likes" => array:2 [▶]
        "name" => "McKenzie Flavius"
        "picture" => array:1 [▶]
        "id" => "186894038315206"
      ]
      "id" => "1687724354827858_1687724421494518"
      "comments" => array:2 [▼
        "data" => array:1 [▼
          0 => array:2 [▼
            "message" => "replied ooh nice"
            "id" => "1687724354827858_1687769078156719" //I need to get picture in this array here!
          ]
        ]
        "paging" => array:1 [▶]
      ]
    ]
    1 => array:4 [▶]
    2 => array:4 [▶]
    3 => array:4 [▶]
    4 => array:4 [▶]
    5 => array:3 [▶]
    6 => array:4 [▶]
    7 => array:4 [▶]
    8 => array:4 [▶]
    9 => array:4 [▶]
    10 => array:4 [▶]
    11 => array:4 [▶]
    12 => array:4 [▶]
  ]
  "paging" => array:1 [▶]
]

一如既往的所有帮助赞赏

1 个答案:

答案 0 :(得分:2)

我想通了,所以将以下参数作为url的一部分传递给facebook。

COMMENT-ID/comments?fields=likes,message,comments,$accessToken;

我需要使用带有参数的{'Sub-Field Info Here'}来获取我想要的子字段,所以要从评论中获取图片,我执行了以下操作:

COMMENT-ID/comments?fields=likes,message,comments{from{picture,name}}, $accessToken;

注意我将{from{picture,name}}放在已传递的comments参数旁边,这意味着撤回的数据将与评论字段相关。所以最终我在这里找回了'图片'和'名字'从评论中给出了类似下面的内容:

"comments" => "from"[
     "picture" => "PICTURE-LINK",
     "name"    => "NAME"
]