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

Issue getting an attachment #4

Closed EwanValentine closed 8 years ago

EwanValentine commented 8 years ago

Hi there,

I'm attempting to get file attachments, but it doesn't seem to be present in the message event.

// MessageHandler - Handles messaged from Facebook page and returns response with template
func MessageHandler(event messenger.Event, opts messenger.MessageOpts, msg messenger.ReceivedMessage) {

    log.Println(msg.Message.Attachment)

        // ... Redacted code
}

The trouble is... msg.Message.Attachment is always nil

EwanValentine commented 8 years ago

I've just been looking at the docs https://developers.facebook.com/docs/messenger-platform/webhook-reference#received_message

In the message received event, shouldn't the attachment field be something like this?

type Message struct {
    Text       string      `json:"text,omiempty"`
    Attachments []*Attachment `json:"attachments,omitempty"`
}
maciekmm commented 8 years ago

Fixed as of 0903473abb5e533738bc7b5870c3b7bc99ee4893