mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-12 10:55:11 +00:00
1.2 KiB
Executable File
1.2 KiB
Executable File
Event
An m3o.com API. For example usage see m3o.com/Event/api.
Endpoints:
Subscribe
Subscribe to messages for a given topic.
https://m3o.com/event/api#Subscribe
package example
import(
"fmt"
"os"
"go.m3o.com/event"
)
// Subscribe to messages for a given topic.
func SubscribeToAtopic() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Subscribe(&event.SubscribeRequest{
Topic: "user",
})
fmt.Println(rsp, err)
}
Publish
Publish a message to the event. Specify a topic to group messages for a specific topic.
https://m3o.com/event/api#Publish
package example
import(
"fmt"
"os"
"go.m3o.com/event"
)
// Publish a message to the event. Specify a topic to group messages for a specific topic.
func PublishAmessage() {
eventService := event.NewEventService(os.Getenv("M3O_API_TOKEN"))
rsp, err := eventService.Publish(&event.PublishRequest{
Message: map[string]interface{}{
"id": "1",
"type": "signup",
"user": "john",
},
Topic: "user",
})
fmt.Println(rsp, err)
}