https://github.com/jjideenschmiede/gocm
Our library to use the cm.com api in golang.
https://github.com/jjideenschmiede/gocm
cm cmdotcom golang golang-library
Last synced: 21 days ago
JSON representation
Our library to use the cm.com api in golang.
- Host: GitHub
- URL: https://github.com/jjideenschmiede/gocm
- Owner: jjideenschmiede
- License: mit
- Created: 2021-10-22T13:23:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-11-05T16:41:30.000Z (over 4 years ago)
- Last Synced: 2025-05-19T23:43:27.702Z (about 1 year ago)
- Topics: cm, cmdotcom, golang, golang-library
- Language: Go
- Homepage: https://www.cm.com/de/app/docs/
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gocm
[](https://golang.org/) [](https://github.com/jjideenschmiede/gocm/actions/workflows/go.yml) [](https://goreportcard.com/report/github.com/jjideenschmiede/gocm) [](https://pkg.go.dev/github.com/jjideenschmiede/gocm)
With this small library it should be possible to send SMS, WhatsApp & Co messages via [cm.com](https://www.cm.com/de-de/). And, of course, to make other functions of the API usable.
## Install
```console
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](https://www.cm.com/app/docs/en/api/business-messaging-api/1.0/index#introduction) you can find an additional description from the manufacturer.
Currently the following channels can be used: **WhatsApp, Push, RCS, Viber, SMS**
```go
// 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)
}
```