FB Graph API:通过API获取对象字段列表的方法

pcv*_*pcv 6 facebook facebook-graph-api

有没有办法如何以编程方式获取特定facebook对象的字段列表?

我知道有相关的文档,但我需要一些内省 - 我们正在构建一个工具,使用户可以从现有字段中进行选择.

我的意思是:给我一个用户字段列表,响应:{"id","name","first_name",...}

或者某种方式如何获取一个对象的所有字段并从中派生出来?

pcv*_*pcv 8

Facebook允许您传递metadata = 1参数.例如

cocacola?metadata=1
Run Code Online (Sandbox Code Playgroud)

为您提供页面的所有可用连接和字段:

  "metadata": {
    "connections": {
      "admins": "https://graph.facebook.com/cocacola/admins",
      "admin_settings": "https://graph.facebook.com/cocacola/admin_settings"
    },
    "fields": [
      {
        "name": "id",
        "description": "The Page's ID. No access token or user `access_token`. `string`."
      },
      {
        "name": "name",
        "description": "The Page's name. No access token or user `access_token`. `string`."
      },
      {
        "name": "link",
        "description": "Link to the page on Facebook. No access token or user `access_token`. `string` containing a valid URL."
      },
      {
        "name": "category_lists",
        "description": "The Page's categories. No access token or user `access_token`. `string`."
      },
      {
        "name": "is_published",
        "description": "Indicates whether the page is published and visible to non-admins. No access token or user `access_token`. `boolean`."
      }
Run Code Online (Sandbox Code Playgroud)

看起来像是官方的,在入门手册中找到它