Documentation
¶
Index ¶
- Constants
- Variables
- type Attachment
- type AttachmentPayload
- type Change
- type Entry
- type Event
- type InstagramChangesHandler
- type InstagramHandler
- type InstagramMentionHandler
- type InstagramMessageHandler
- type InstagramMessagingHandler
- type InstagramPostbackHandler
- type InstagramReferralHandler
- type InstagramStoryInsightsHandler
- type Mention
- type Message
- type Messaging
- type MessagingHeader
- type MessagingMessage
- type MessagingPostback
- type MessagingReferral
- type MetaWebhookOptions
- func (MetaWebhookOptions) CompileSchema() Option
- func (MetaWebhookOptions) CustomHeaderSigName(name string) Option
- func (MetaWebhookOptions) IgnoreEchoMessages(ignore bool) Option
- func (MetaWebhookOptions) InstagramChangesHandler(fn InstagramChangesHandler) Option
- func (MetaWebhookOptions) InstagramHandler(fn InstagramHandler) Option
- func (MetaWebhookOptions) InstagramMentionHandler(fn InstagramMentionHandler) Option
- func (MetaWebhookOptions) InstagramMessageHandler(fn InstagramMessageHandler) Option
- func (MetaWebhookOptions) InstagramMessagingHandler(fn InstagramMessagingHandler) Option
- func (MetaWebhookOptions) InstagramPostbackHandler(fn InstagramPostbackHandler) Option
- func (MetaWebhookOptions) InstagramReferralHandler(fn InstagramReferralHandler) Option
- func (MetaWebhookOptions) InstagramStoryInsightsHandler(fn InstagramStoryInsightsHandler) Option
- func (MetaWebhookOptions) Secret(secret string) Option
- func (MetaWebhookOptions) Token(token string) Option
- type Object
- type Option
- type Postback
- type Referral
- type StoryInsights
- type Webhooks
- func (h Webhooks) Handle(ctx context.Context, event Event) error
- func (hooks Webhooks) ParsePayload(body []byte) (Event, error)
- func (hooks Webhooks) ValidatePayload(body []byte) error
- func (hooks Webhooks) VerifyPayload(body []byte, headers map[string]string) error
- func (hooks Webhooks) VerifyToken(queryValues map[string]string) (string, error)
- type WebhooksHandler
Constants ¶
const (
HeaderSignatureName = "X-Hub-Signature-256"
)
Variables ¶
var ( ErrChangesFieldNotImplemented = errors.New("changes field not implemented") ErrInstagramMentionHandlerNotDefined = errors.New("instagram mentions handler not defined") ErrInstagramStoryInsightsHandlerNotDefined = errors.New("instagram story insights handler not defined") )
var ( ErrMessagingTypeNotImplemented = errors.New("messaging type not implemented") ErrInstagramMessageHandlerNotDefined = errors.New("instagram message handler not defined") ErrInstagramPostbackHandlerNotDefined = errors.New("instagram postback handler not defined") ErrInstagramReferralHandlerNotDefined = errors.New("instagram referral handler not defined") )
var ( ErrObjectRequired = errors.New("object required") ErrObjectNotSupported = errors.New("object not supported") )
var ( ErrMissingHubSignatureHeader = errors.New("missing signature value") ErrHMACVerificationFailed = errors.New("HMAC verification failed") ErrParsingPayload = errors.New("parsing payload") ErrInvalidPayload = errors.New("invalid payload") )
var ( ErrSchemaCompile = errors.New("failed to compile schema") ErrMissingSchema = errors.New("missing embedded schema") )
var (
ErrApplyingOption = errors.New("error applying option")
)
var (
ErrParsingEntry = errors.New("parsing entry")
)
var (
ErrVerifyTokenFailed = errors.New("invalid verify_token value")
)
var Options = MetaWebhookOptions{}
Options is a namespace var for configuration options
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct { Type string `json:"type,omitempty"` Payload AttachmentPayload `json:"payload,omitempty"` }
type AttachmentPayload ¶ added in v0.3.0
type Change ¶
type Change struct { Field string `json:"field,omitempty"` Value interface{} `json:"value,omitempty"` }
func (*Change) UnmarshalJSON ¶
type Entry ¶
type Entry struct { Id string `json:"id"` Time int64 `json:"time"` Messaging []Messaging `json:"messaging,omitempty"` Changes []Change `json:"changes,omitempty"` }
func (*Entry) UnmarshalJSON ¶ added in v0.7.0
type InstagramChangesHandler ¶
type InstagramChangesHandler interface { InstagramMentionHandler InstagramStoryInsightsHandler }
type InstagramHandler ¶
type InstagramHandler interface { InstagramChangesHandler InstagramMessagingHandler }
type InstagramMentionHandler ¶
type InstagramMessageHandler ¶
type InstagramMessagingHandler ¶
type InstagramMessagingHandler interface { InstagramMessageHandler InstagramPostbackHandler InstagramReferralHandler }
type Message ¶
type Message struct { Id string `json:"mid,omitempty"` Text string `json:"text,omitempty"` Attachments []Attachment `json:"attachments,omitempty"` Referral *Referral `json:"referral,omitempty"` IsDeleted bool `json:"is_deleted,omitempty"` IsEcho bool `json:"is_echo,omitempty"` IsUnsupported bool `json:"is_unsupported,omitempty"` ReplyTo *struct { // one Id string `json:"mid,omitempty"` // or another Story *struct { ID string `json:"id,omitempty"` URL string `json:"url,omitempty"` } `json:"story,omitempty"` } `json:"reply_to,omitempty"` QuickReply *struct { Payload string `json:"payload,omitempty"` } `json:"quick_reply,omitempty"` }
type Messaging ¶
type Messaging struct {
Type interface{} `json:"-"`
}
Wrapper struct for types MessagingMessage, MessagingPostback and MessagingReferral
func (*Messaging) UnmarshalJSON ¶ added in v0.8.0
type MessagingHeader ¶ added in v0.8.0
type MessagingMessage ¶ added in v0.8.0
type MessagingMessage struct { MessagingHeader Message Message `json:"message,omitempty"` }
https://developers.facebook.com/docs/messenger-platform/instagram/features/webhook/#messages
type MessagingPostback ¶ added in v0.8.0
type MessagingPostback struct { MessagingHeader Postback Postback `json:"postback,omitempty"` }
type MessagingReferral ¶ added in v0.8.0
type MessagingReferral struct { MessagingHeader Referral Referral `json:"referral,omitempty"` }
https://developers.facebook.com/docs/messenger-platform/instagram/features/webhook/#igme
type MetaWebhookOptions ¶
type MetaWebhookOptions struct{}
MetaWebhookOptions is a namespace for configuration option methods
func (MetaWebhookOptions) CompileSchema ¶ added in v0.5.0
func (MetaWebhookOptions) CompileSchema() Option
Ensures embedded JSON schema is compiled
func (MetaWebhookOptions) CustomHeaderSigName ¶ added in v0.5.0
func (MetaWebhookOptions) CustomHeaderSigName(name string) Option
Sets a custom header signature name
func (MetaWebhookOptions) IgnoreEchoMessages ¶ added in v0.8.0
func (MetaWebhookOptions) IgnoreEchoMessages(ignore bool) Option
func (MetaWebhookOptions) InstagramChangesHandler ¶
func (MetaWebhookOptions) InstagramChangesHandler(fn InstagramChangesHandler) Option
Sets all InstagramChanges handlers
func (MetaWebhookOptions) InstagramHandler ¶
func (MetaWebhookOptions) InstagramHandler(fn InstagramHandler) Option
Sets all Instagram handlers
func (MetaWebhookOptions) InstagramMentionHandler ¶
func (MetaWebhookOptions) InstagramMentionHandler(fn InstagramMentionHandler) Option
Sets the InstagramMentionHandler, see https://developers.facebook.com/docs/instagram-api/guides/mentions
func (MetaWebhookOptions) InstagramMessageHandler ¶
func (MetaWebhookOptions) InstagramMessageHandler(fn InstagramMessageHandler) Option
Sets the InstagramMessageHandler, see https://developers.facebook.com/docs/messenger-platform/instagram/features/webhook/#messages
func (MetaWebhookOptions) InstagramMessagingHandler ¶
func (MetaWebhookOptions) InstagramMessagingHandler(fn InstagramMessagingHandler) Option
Sets all InstagramMessaging handlers
func (MetaWebhookOptions) InstagramPostbackHandler ¶
func (MetaWebhookOptions) InstagramPostbackHandler(fn InstagramPostbackHandler) Option
Sets the InstagramPostbackHandler, see https://developers.facebook.com/docs/messenger-platform/instagram/features/webhook/#messaging-postbacks
func (MetaWebhookOptions) InstagramReferralHandler ¶
func (MetaWebhookOptions) InstagramReferralHandler(fn InstagramReferralHandler) Option
Sets the InstagramReferralHandler, see https://developers.facebook.com/docs/messenger-platform/instagram/features/webhook/#igme
func (MetaWebhookOptions) InstagramStoryInsightsHandler ¶
func (MetaWebhookOptions) InstagramStoryInsightsHandler(fn InstagramStoryInsightsHandler) Option
Sets the InstagramStoryInsightsHandler, see https://developers.facebook.com/docs/instagram-api/guides/webhooks#capturing-story-insights
func (MetaWebhookOptions) Secret ¶
func (MetaWebhookOptions) Secret(secret string) Option
Sets the Facebook APP Secret
func (MetaWebhookOptions) Token ¶
func (MetaWebhookOptions) Token(token string) Option
Sets the Facebook APP webhook subscription verify token
type Object ¶
type Object string
const (
Instagram Object = "instagram"
)
func (*Object) FromString ¶
func (Object) MarshalJSON ¶
func (*Object) UnmarshalJSON ¶
type StoryInsights ¶ added in v0.8.0
type StoryInsights struct { MediaID string `json:"media_id,omitempty"` Exits int `json:"exits,omitempty"` Replies int `json:"replies,omitempty"` Reach int `json:"reach,omitempty"` TapsForward int `json:"taps_forward,omitempty"` TapsBack int `json:"taps_back,omitempty"` Impressions int `json:"impressions,omitempty"` }
type Webhooks ¶
type Webhooks struct {
// contains filtered or unexported fields
}
Webhooks instance contains all methods needed to process object events