mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 18:44:26 +00:00
2.3 KiB
Executable File
2.3 KiB
Executable File
Stream
An m3o.com API. For example usage see m3o.com/Stream/api.
Endpoints:
CreateChannel
Create a channel with a given name and description. Channels are created automatically but this allows you to specify a description that's persisted for the lifetime of the channel.
https://m3o.com/stream/api#CreateChannel
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// Create a channel with a given name and description. Channels are created automatically but
// this allows you to specify a description that's persisted for the lifetime of the channel.
func CreateChannel() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.CreateChannel(&stream.CreateChannelRequest{
Description: "The channel for all things",
Name: "general",
})
fmt.Println(rsp, err)
}
SendMessage
Send a message to the stream.
https://m3o.com/stream/api#SendMessage
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// Send a message to the stream.
func SendMessage() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.SendMessage(&stream.SendMessageRequest{
Channel: "general",
Text: "Hey checkout this tweet https://twitter.com/m3oservices/status/1455291054295498752",
})
fmt.Println(rsp, err)
}
ListMessages
List messages for a given channel
https://m3o.com/stream/api#ListMessages
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List messages for a given channel
func ListMessages() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListMessages(&stream.ListMessagesRequest{
Channel: "general",
})
fmt.Println(rsp, err)
}
ListChannels
List all the active channels
https://m3o.com/stream/api#ListChannels
package example
import(
"fmt"
"os"
"go.m3o.com/stream"
)
// List all the active channels
func ListChannels() {
streamService := stream.NewStreamService(os.Getenv("M3O_API_TOKEN"))
rsp, err := streamService.ListChannels(&stream.ListChannelsRequest{
})
fmt.Println(rsp, err)
}