How can I know if a node returned from Facebook Graph API is a profile or a page?

前端 未结 1 1252
攒了一身酷
攒了一身酷 2021-02-05 17:41

I one part of a site I\'m programming, users can add facebook pages to a list manually by manually entering the username or id of each page. Once submitted, I connect to Faceboo

1条回答
  •  有刺的猬
    2021-02-05 18:48

    The type of an object usually comes under meta data and is not returned with a request unless you specify. In order to make a request for the type of the object, simple add ?metadata=1 at the end of your request. Something like:

    http://graph.facebook.com/{object_id}?metadata=1
    

    For example, the request:

    http://graph.facebook.com/1013953243?metadata=1
    

    will return the following data:

    {
       "id": "1013953243",
       "name": "Nilo V\u00e9lez",
       "first_name": "Nilo",
       "last_name": "V\u00e9lez",
       "gender": "male",
       "locale": "en_US",
       "username": "nilovelez",
       "metadata": {
          "connections": XXX
           .
           .
           .
           .
           .
           .
          "type": "user"
       }
    }
    

    0 讨论(0)
提交回复
热议问题