1
0
mirror of synced 2024-11-22 04:46:05 +03:00

cleanup for PR #51

This commit is contained in:
Ayomide Onigbinde 2019-01-04 10:22:09 +01:00
parent 830f72e96e
commit 51846268a9
4 changed files with 4 additions and 23 deletions

View File

@ -11,10 +11,6 @@ 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")
@ -47,7 +43,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, profileField)
p, err := client.ProfileByID(m.Sender.ID, []string{"name", "first_name", "last_name", "profile_pic"})
if err != nil {
fmt.Println("Something went wrong!", err)
}

View File

@ -11,11 +11,6 @@ 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)")
@ -57,7 +52,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, profileField)
p, err := client.ProfileByID(m.Sender.ID, []string{"name", "first_name", "last_name", "profile_pic"})
if err != nil {
fmt.Println("Something went wrong!", err)
}

View File

@ -14,11 +14,6 @@ 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"
@ -59,7 +54,7 @@ func main() {
client.HandleMessage(func(m messenger.Message, r *messenger.Response) {
log.Printf("%v (Sent, %v)\n", m.Text, m.Time.Format(time.UnixDate))
p, err := client.ProfileByID(m.Sender.ID, profileField)
p, err := client.ProfileByID(m.Sender.ID, []string{"name", "first_name", "last_name", "profile_pic"})
if err != nil {
log.Println("Failed to fetch user profile:", err)
}

View File

@ -5,7 +5,6 @@ import (
"crypto/hmac"
"crypto/sha1"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
@ -154,7 +153,7 @@ func (m *Messenger) Handler() http.Handler {
// 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
// At the time of writing (2019-01-04), these fields are
// - Name
// - First Name
// - Last Name
@ -168,10 +167,6 @@ func (m *Messenger) ProfileByID(id int64, profileFields []string) (Profile, erro
return p, err
}
if len(profileFields) == 0 {
return p, errors.New("Profile field cannot be empty")
}
fields := strings.Join(profileFields, ",")
req.URL.RawQuery = "fields=" + fields + "&access_token=" + m.token