Facebook Graph API /me/Feed V2.4 vs V2.3

自古美人都是妖i 提交于 2019-12-07 19:12:29

问题


I'm trying to access all feeds a facebook user using the Graph API .

However I'm getting quite different responses from V2.3 to V2.4 .

In version 2.4 using the instruction / me / Feed not receive complete information of the posts just returns some fields , while in the previous version had access to all the information. As can be seen the difference in the following answers.

V2.4

{
"data": [
    {
      "message": "A brincar com o Xico Zé.. ;)",
      "created_time": "2015-07-11T18:23:59+0000",
      "id": "10153293007088673_120153297333223673"
    },
    {
      "message": "Ana Simões e Pedro Simões este é que é bom para a Liliana Assunção..",
      "story": "Diogo Lopes shared Classic Hits 4FM's video.",
      "created_time": "2015-07-11T14:20:59+0000",
      "id": "10153293007088673_1360153296966998673"
    }
],
  "paging": {
    . . .
  }
}

V2.3

{
  "data": [
    {
      "id": "10153129496378673_120153297333223673",
      "from": {
        "name": "Diogo Lopes",
        "id": "10153129496378673"
      },
      "message": "A brincar com o Xico Zé.. ;)",
      "picture": "",
      "link": "",
      "name": "Diogo Lopes on Instagram: “A brincar com o Xico Zé.. ;)”",
      "caption": "Diogo Lopes on Instagram: “A brincar com o Xico Zé.. ;)”",
      "description": "A brincar com o Xico Zé.. ;)",
      "icon": "https://www.facebook.com/images/icons/post.gif",
      "actions": [
. . .
      ],
      "privacy": {
        "value": "ALL_FRIENDS",
        "description": "Your friends",
        "friends": "",
        "allow": "",
        "deny": ""
      },
      "type": "photo",
      "status_type": "added_photos",
      "object_id": "120153297333233673",
      "application": {
        ". . ."
      },
      "created_time": "2015-07-11T18:23:59+0000",
      "updated_time": "2015-07-12T20:50:19+0000",
      "is_hidden": false,
      "subscribed": true,
      "is_expired": false,
      "likes": {
        . . .
        ],
        "paging": {
          . . .
        }
      },
      "comments": {
        "data": [
         . . .
        ],
        "paging": {
          . . .
        }
      }
    },
    {
      "id": "10153129496378673_1360153296966998673",
      "from": {
        "name": "Diogo Lopes",
        "id": "10153129496378673"
      },
      "to": {
        . . .      },
      "message": "………....",
      "message_tags": {
. . .
      },
      "story": "Diogo Lopes shared Classic Hits 4FM's video.",
      "story_tags": {
        "0": [
          {
            "id": "10153129496378673",
            "name": "Diogo Lopes",
            "type": "user",
            "offset": 0,
            "length": 11
          }
        ],
        "19": [
          {
            "id": "125659037470226",
            "name": "Classic Hits 4FM",
            "type": "page",
            "offset": 19,
            "length": 16
          }
        ],
        "38": [
          {
            "id": "874724002563722",
            "name": "",
            "offset": 38,
            "length": 5
          }
        ]
      },
      "picture": "https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-xta1/v/t15.0-10/s130x130/11331624_874724179230371_2123630990_n.jpg?oh=701da51ed6690c70ba8d3e7ba5cbb58c&oe=56273FFC&__gda__=1448812275_e37392fe85f01402fa0565b0086df710",
      "link": "https://www.facebook.com/ClassicHits4FM/videos/874724002563722/",
      "source": "https://video.xx.fbcdn.net/hvideo-xtp1/v/t42.1790-2/11656282_889978921061393_14476072_n.mp4?efg=eyJybHIiOjQ4NCwicmxhIjo1MTJ9&rl=484&vabr=269&oh=a4e7e8ec985cf5374082e5c9639d5b06&oe=55A5ED2C",
      "name": "Classic Hits 4FM",
      "description": "A Giant Nope!!!

Would you go on this Swiss Ride?",
      "actions": [
. . .
      ],
      "privacy": {
        "value": "EVERYONE",
        "description": "Public",
        "friends": "",
        "allow": "",
        "deny": ""
      },
      "type": "video",
      "status_type": "mobile_status_update",
      "created_time": "2015-07-11T14:20:59+0000",
      "updated_time": "2015-07-11T21:28:06+0000",
      "is_hidden": false,
      "subscribed": true,
      "is_expired": false,
      "likes": {
        . . .
        ],
        "paging": { . . . }
      },
      "comments": {
}
…
}

Someone can help me know how I can get a similar response in V2.4 to V2.3??

Obs. My facebook aplication have user_posts Permission.


回答1:


Since the upgrade in Graph API i.e. version 2.4. You have to specifically pass a fields parameter with the relevant keyword of which, data you would like to retrieve.

Please refer to this document of Facebook Developers

Changes from v2.3 to v2.4

Declarative Fields

To try to improve performance on mobile networks, Nodes and Edges in v2.4 requires that you explicitly request the field(s) you need for your GET requests. For example, GET /v2.4/me/feed no longer includes likes and comments by default, but GET /v2.4/me/feed?fields=comments,likes will return the data. For more details see the docs on how to request specific fields.

An example of v2.4:

<page_id>/feed?fields=id,message,picture,likes,shares,comments


来源:https://stackoverflow.com/questions/31390197/facebook-graph-api-me-feed-v2-4-vs-v2-3

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