jjideenschmiede / gocm

Our library to use the cm.com api in golang.

Home Page:https://www.cm.com/de/app/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gocm

GitHub go.mod Go version of a Go module Go Go Report Card Go Doc

With this small library it should be possible to send SMS, WhatsApp & Co messages via cm.com. And, of course, to make other functions of the API usable.

Install

go get github.com/jjideenschmiede/gocm

How to use?

Business Messaging

In order to send one, or more messages via the Business Messages API, you can use the following function. Here you can find an additional description from the manufacturer.

Currently the following channels can be used: WhatsApp, Push, RCS, Viber, SMS

// Define body
body := gocm.MessageBody{
    Messages: gocm.MessageBodyMessages{
        Authentication: gocm.MessageBodyAuthentication{
            Producttoken: "",
        },
        Msg: []gocm.MessageBodyMsg{},
    },
}

// Create a message
body.Messages.Msg = append(body.Messages.Msg, gocm.MessageBodyMsg{
    AllowedChannels: []string{"SMS"},
    From:            "Test",
    To:              []gocm.MessageBodyTo{},
    Body: gocm.MessageBodyBody{
        Type:    "auto",
        Content: "Test message",
    },
})

// Add receiver
body.Messages.Msg[0].To = append(body.Messages.Msg[0].To, gocm.MessageBodyTo{
    Number: "004941521234567",
})

// Send message
message, err := gocm.Message(body)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println(message)
}

About

Our library to use the cm.com api in golang.

https://www.cm.com/de/app/docs/

License:MIT License


Languages

Language:Go 100.0%