added profile field to examples to fix failing builds
This commit is contained in:
parent
92e06df4a9
commit
2543a5afbb
@ -11,6 +11,10 @@ import (
|
||||
"github.com/paked/messenger"
|
||||
)
|
||||
|
||||
//profileField is a slice of strings of the user profile field the developer wants access
|
||||
var (
|
||||
profileField = []string{"name", "first_name", "last_name", "profile_pic"}
|
||||
)
|
||||
var (
|
||||
verifyToken = flag.String("verify-token", "mad-skrilla", "The token used to verify facebook (required)")
|
||||
verify = flag.Bool("should-verify", false, "Whether or not the app should verify itself")
|
||||
@ -43,7 +47,7 @@ func main() {
|
||||
client.HandleMessage(func(m messenger.Message, r *messenger.Response) {
|
||||
fmt.Printf("%v (Sent, %v)\n", m.Text, m.Time.Format(time.UnixDate))
|
||||
|
||||
p, err := client.ProfileByID(m.Sender.ID)
|
||||
p, err := client.ProfileByID(m.Sender.ID, profileField)
|
||||
if err != nil {
|
||||
fmt.Println("Something went wrong!", err)
|
||||
}
|
||||
|
@ -11,6 +11,11 @@ import (
|
||||
"github.com/paked/messenger"
|
||||
)
|
||||
|
||||
//profileField is a slice of strings of the user profile field the developer wants access
|
||||
var (
|
||||
profileField = []string{"name", "first_name", "last_name", "profile_pic"}
|
||||
)
|
||||
|
||||
var (
|
||||
serverURL = flag.String("serverURL", "", "The server (webview) URL, must be https (required)")
|
||||
verifyToken = flag.String("verify-token", "mad-skrilla", "The token used to verify facebook (required)")
|
||||
@ -52,7 +57,7 @@ func main() {
|
||||
client.HandleMessage(func(m messenger.Message, r *messenger.Response) {
|
||||
fmt.Printf("%v (Sent, %v)\n", m.Text, m.Time.Format(time.UnixDate))
|
||||
|
||||
p, err := client.ProfileByID(m.Sender.ID)
|
||||
p, err := client.ProfileByID(m.Sender.ID, profileField)
|
||||
if err != nil {
|
||||
fmt.Println("Something went wrong!", err)
|
||||
}
|
||||
|
@ -14,6 +14,11 @@ import (
|
||||
"github.com/paked/messenger"
|
||||
)
|
||||
|
||||
//profileField is a slice of strings of the user profile field the developer wants access
|
||||
var (
|
||||
profileField = []string{"name", "first_name", "last_name", "profile_pic"}
|
||||
)
|
||||
|
||||
const (
|
||||
webhooksPath = "/webhooks"
|
||||
loginPath = "/signin"
|
||||
|
10
messenger.go
10
messenger.go
@ -150,7 +150,15 @@ func (m *Messenger) Handler() http.Handler {
|
||||
return m.mux
|
||||
}
|
||||
|
||||
// ProfileByID retrieves the Facebook user profile associated with that ID
|
||||
// ProfileByID retrieves the Facebook user profile associated with that ID.
|
||||
// According to the messenger docs: https://developers.facebook.com/docs/messenger-platform/identity/user-profile,
|
||||
// Developers must ask for access except for some fields that are accessible without permissions.
|
||||
//
|
||||
// These fields are
|
||||
// - Name
|
||||
// - First Name
|
||||
// - Last Name
|
||||
// - Profile Picture
|
||||
func (m *Messenger) ProfileByID(id int64, profileFields []string) (Profile, error) {
|
||||
p := Profile{}
|
||||
url := fmt.Sprintf("%v%v", ProfileURL, id)
|
||||
|
Loading…
Reference in New Issue
Block a user