remove default profile field
This commit is contained in:
parent
61add2ce3d
commit
92e06df4a9
17
messenger.go
17
messenger.go
@ -5,6 +5,7 @@ import (
|
|||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -25,11 +26,6 @@ const (
|
|||||||
MessengerProfileURL = "https://graph.facebook.com/v2.6/me/messenger_profile"
|
MessengerProfileURL = "https://graph.facebook.com/v2.6/me/messenger_profile"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// NOTE: If you change this slice you should update the comment on the ProfileByID function below too.
|
|
||||||
defaultProfileFields = []string{"name", "first_name", "last_name", "profile_pic"}
|
|
||||||
)
|
|
||||||
|
|
||||||
// Options are the settings used when creating a Messenger client.
|
// Options are the settings used when creating a Messenger client.
|
||||||
type Options struct {
|
type Options struct {
|
||||||
// Verify sets whether or not to be in the "verify" mode. Used for
|
// Verify sets whether or not to be in the "verify" mode. Used for
|
||||||
@ -155,14 +151,7 @@ func (m *Messenger) Handler() http.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ProfileByID retrieves the Facebook user profile associated with that ID
|
// ProfileByID retrieves the Facebook user profile associated with that ID
|
||||||
// when no profile fields are specified it uses some sane defaults.
|
func (m *Messenger) ProfileByID(id int64, profileFields []string) (Profile, error) {
|
||||||
//
|
|
||||||
// These default fields are:
|
|
||||||
// - Name
|
|
||||||
// - First name
|
|
||||||
// - Last name
|
|
||||||
// - Profile picture
|
|
||||||
func (m *Messenger) ProfileByID(id int64, profileFields ...string) (Profile, error) {
|
|
||||||
p := Profile{}
|
p := Profile{}
|
||||||
url := fmt.Sprintf("%v%v", ProfileURL, id)
|
url := fmt.Sprintf("%v%v", ProfileURL, id)
|
||||||
|
|
||||||
@ -172,7 +161,7 @@ func (m *Messenger) ProfileByID(id int64, profileFields ...string) (Profile, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(profileFields) == 0 {
|
if len(profileFields) == 0 {
|
||||||
profileFields = defaultProfileFields
|
return p, errors.New("Profile field cannot be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
fields := strings.Join(profileFields, ",")
|
fields := strings.Join(profileFields, ",")
|
||||||
|
Loading…
Reference in New Issue
Block a user