maciekmm / messenger-platform-go-sdk

:envelope: A GO SDK for Facebook's messenger-platform: https://developers.facebook.com/docs/messenger-platform
MIT License
110 stars 27 forks source link

Event ID can be string or int #2

Closed marselester closed 8 years ago

marselester commented 8 years ago

Hi Maciej,

Unfortunately Facebook is not consistent with entry IDs. For messages it uses strings {"object":"page","entry":[{"id":"123",, but for postbacks ints {"object":"page","entry":[{"id":123,.

Not sure what would be a proper way to handle that, I use json.Number and hope Facebook migrates to strings eventually.

type Event struct {
    ID   json.Number `json:"id"`
    Time int64       `json:"time"`
}
maciekmm commented 8 years ago

@marselester thanks for bringing this up. I think implementing json.Unmarshaler to handle conversion would be a better idea. If facebook finally decides to switch to strings as they plan it'd be easy to just get rid.