cleanup for PR #51
This commit is contained in:
parent
830f72e96e
commit
51846268a9
@ -11,10 +11,6 @@ import (
|
|||||||
"github.com/paked/messenger"
|
"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 (
|
var (
|
||||||
verifyToken = flag.String("verify-token", "mad-skrilla", "The token used to verify facebook (required)")
|
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")
|
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) {
|
client.HandleMessage(func(m messenger.Message, r *messenger.Response) {
|
||||||
fmt.Printf("%v (Sent, %v)\n", m.Text, m.Time.Format(time.UnixDate))
|
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 {
|
if err != nil {
|
||||||
fmt.Println("Something went wrong!", err)
|
fmt.Println("Something went wrong!", err)
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,6 @@ import (
|
|||||||
"github.com/paked/messenger"
|
"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 (
|
var (
|
||||||
serverURL = flag.String("serverURL", "", "The server (webview) URL, must be https (required)")
|
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)")
|
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) {
|
client.HandleMessage(func(m messenger.Message, r *messenger.Response) {
|
||||||
fmt.Printf("%v (Sent, %v)\n", m.Text, m.Time.Format(time.UnixDate))
|
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 {
|
if err != nil {
|
||||||
fmt.Println("Something went wrong!", err)
|
fmt.Println("Something went wrong!", err)
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,6 @@ import (
|
|||||||
"github.com/paked/messenger"
|
"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 (
|
const (
|
||||||
webhooksPath = "/webhooks"
|
webhooksPath = "/webhooks"
|
||||||
loginPath = "/signin"
|
loginPath = "/signin"
|
||||||
@ -59,7 +54,7 @@ func main() {
|
|||||||
client.HandleMessage(func(m messenger.Message, r *messenger.Response) {
|
client.HandleMessage(func(m messenger.Message, r *messenger.Response) {
|
||||||
log.Printf("%v (Sent, %v)\n", m.Text, m.Time.Format(time.UnixDate))
|
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 {
|
if err != nil {
|
||||||
log.Println("Failed to fetch user profile:", err)
|
log.Println("Failed to fetch user profile:", err)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"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,
|
// 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.
|
// 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
|
// - Name
|
||||||
// - First Name
|
// - First Name
|
||||||
// - Last Name
|
// - Last Name
|
||||||
@ -168,10 +167,6 @@ func (m *Messenger) ProfileByID(id int64, profileFields []string) (Profile, erro
|
|||||||
return p, err
|
return p, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(profileFields) == 0 {
|
|
||||||
return p, errors.New("Profile field cannot be empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
fields := strings.Join(profileFields, ",")
|
fields := strings.Join(profileFields, ",")
|
||||||
|
|
||||||
req.URL.RawQuery = "fields=" + fields + "&access_token=" + m.token
|
req.URL.RawQuery = "fields=" + fields + "&access_token=" + m.token
|
||||||
|
Loading…
Reference in New Issue
Block a user