How to detect default avatar on facebook?

前端 未结 4 792
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-14 07:17

How to detect default avatar on the link like this: https://graph.facebook.com/\'.$id.\'/picture?type=large? Is it the only way to get avatars (male/female) fr

4条回答
  •  青春惊慌失措
    2021-01-14 07:53

    If you are already making a call to the Graph API to get user data like the avatar, just include picture in the fields param when you make your first call to Graph API, then the response will include the is_silhouette offset, if it's set to true the user has the default avatar.

    Request:

    https://graph.facebook.com/v2.7/me?access_token=[token]&fields=name,picture
    

    Response:

    {
        "id": "100103095474350",
        "name": "John Smith",
        "picture": {
            "data": {
                "is_silhouette": true,
                "url": "https://scontent.xx.fbcdn.net/v/...jpg"
            }
        }
    }
    

提交回复
热议问题