Skip to content
Snippets Groups Projects
Commit dd51571d authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Update to Facebook Graph API v9.0, remove unused Facebook profile request fields.

parent f32e880b
Branches
Tags
No related merge requests found
...@@ -8,6 +8,8 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr ...@@ -8,6 +8,8 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
- Make metrics prefix configurable, default to fixed value. - Make metrics prefix configurable, default to fixed value.
- Build with Go 1.15.5 release. - Build with Go 1.15.5 release.
- Skip logging Lua errors raised by explicit runtime calls to the `error({msg, code})` built-in. - Skip logging Lua errors raised by explicit runtime calls to the `error({msg, code})` built-in.
- Update to Facebook Graph API v9.0.
- Facebook authentication no longer requires access to gender, locale, and timezone data.
### Fixed ### Fixed
- Better handling of SSL connections in development configurations. - Better handling of SSL connections in development configurations.
......
...@@ -81,9 +81,6 @@ type FacebookProfile struct { ...@@ -81,9 +81,6 @@ type FacebookProfile struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Email string `json:"email"` Email string `json:"email"`
Gender string `json:"gender"`
Locale string `json:"locale"`
Timezone float64 `json:"timezone"`
} }
type facebookPagingCursors struct { type facebookPagingCursors struct {
...@@ -194,8 +191,8 @@ dAUK75fDiSKxH3fzvc1D1PFMqT+1i4SvZPLQFCE= ...@@ -194,8 +191,8 @@ dAUK75fDiSKxH3fzvc1D1PFMqT+1i4SvZPLQFCE=
func (c *Client) GetFacebookProfile(ctx context.Context, accessToken string) (*FacebookProfile, error) { func (c *Client) GetFacebookProfile(ctx context.Context, accessToken string) (*FacebookProfile, error) {
c.logger.Debug("Getting Facebook profile", zap.String("token", accessToken)) c.logger.Debug("Getting Facebook profile", zap.String("token", accessToken))
path := "https://graph.facebook.com/v5.0/me?access_token=" + url.QueryEscape(accessToken) + path := "https://graph.facebook.com/v9.0/me?access_token=" + url.QueryEscape(accessToken) +
"&fields=" + url.QueryEscape("name,email,gender,locale,timezone") "&fields=" + url.QueryEscape("name,email")
var profile FacebookProfile var profile FacebookProfile
err := c.request(ctx, "facebook profile", path, nil, &profile) err := c.request(ctx, "facebook profile", path, nil, &profile)
if err != nil { if err != nil {
...@@ -213,7 +210,7 @@ func (c *Client) GetFacebookFriends(ctx context.Context, accessToken string) ([] ...@@ -213,7 +210,7 @@ func (c *Client) GetFacebookFriends(ctx context.Context, accessToken string) ([]
after := "" after := ""
for { for {
// In FB Graph API 2.0+ this only returns friends that also use the same app. // In FB Graph API 2.0+ this only returns friends that also use the same app.
path := "https://graph.facebook.com/v5.0/me/friends?access_token=" + url.QueryEscape(accessToken) path := "https://graph.facebook.com/v9.0/me/friends?access_token=" + url.QueryEscape(accessToken)
if after != "" { if after != "" {
path += "&after=" + after path += "&after=" + after
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment