From e4a27db6112b741cdb391f70f79022bc78d072e0 Mon Sep 17 00:00:00 2001 From: Michael Tibben Date: Mon, 10 Apr 2023 20:09:43 +1000 Subject: [PATCH] Add picture field to facebook --- facebook/verify.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/facebook/verify.go b/facebook/verify.go index 67a25d2..aab9934 100644 --- a/facebook/verify.go +++ b/facebook/verify.go @@ -12,9 +12,14 @@ const facebookAPI = "https://graph.facebook.com/v2.9/" // // Note that user ids are unique to each app. type User struct { - ID string `json:"id"` - Name string `json:"name"` - Email string `json:"email"` + ID string `json:"id"` + Name string `json:"name"` + Email string `json:"email"` + Picture struct { + Data struct { + URL string `json:"url"` + } `json:"data"` + } `json:"picture"` } // client is a Facebook client for obtaining the current User. @@ -36,6 +41,6 @@ func (c *client) Me() (*User, *http.Response, error) { // Facebook returns JSON as Content-Type text/javascript :( // Set Accept header to receive proper Content-Type application/json // so Sling will decode into the struct - resp, err := c.sling.New().Set("Accept", "application/json").Get("me?fields=name,email").ReceiveSuccess(user) + resp, err := c.sling.New().Set("Accept", "application/json").Get("me?fields=name,email,picture").ReceiveSuccess(user) return user, resp, err }