JSON Parse Facebook评论Google表格

时间:2017-04-16 11:47:36

标签: json facebook-graph-api google-sheets-api

我可以通过URLFetch在Google表格中成功获取Facebook洞察的评论。

然后我尝试将响应解析为名为result的变量。

var result = JSON.parse(response.getContentText());

网址提取的结果如下:

{
   "created_time": "2017-04-16T11:00:10+0000",
   "message": "A historic vote on the powers of Turkey's president is under way.",
   "actions": [
      {
         "name": "Share",
         "link": "https://www.facebook.com/bbcnews/posts/10154586714572217"
      }
   ],
   "application": {
      "category": "Business",
      "link": "http://socialflow.com/",
      "name": "SocialFlow",
      "namespace": "socialflowapp",
      "id": "128869720483178"
   },
   "caption": "bbc.co.uk",
   "comments": {
      "data": [
         {
            "created_time": "2017-04-16T11:01:40+0000",
            "from": {
               "name": "xxx",
               "id": "xxx"
            },
            "message": "We are not divided.. ! This is just an election of the system. Stop  brainwashing you idiots!",
            "can_remove": false,
            "like_count": 156,
            "user_likes": false,
            "id": "10154586714572217_10154586716852217"
         },

如果我尝试选择'标题'使用result.caption它会根据需要返回标题。然而,我真正想要的是每条评论的信息。

我已经尝试过result.comments.message,但是已经失败了。有谁知道怎么回事?

干杯

马特

0 个答案:

没有答案