2021-05-06 16:53:59 +02:00
|
|
|
# TextMagic
|
|
|
|
|
|
|
|
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://docs.textmagic.com/#section/Go/Usage-Example)
|
|
|
|
|
|
|
|
## Prerequisites
|
|
|
|
|
2021-05-06 17:01:53 +02:00
|
|
|
You will need to have a [TextMagic](https://www.textmagic.com/) account and
|
|
|
|
`UserName` and `API KEY` from TextMagic.[(api-keys)](https://my.textmagic.com/online/api/rest-api/keys)
|
2021-05-06 16:53:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/nikoksr/notify"
|
|
|
|
"github.com/nikoksr/notify/service/textmagic"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
2021-05-26 11:32:48 +02:00
|
|
|
textMagicService := textmagic.New("YOUR_USER_NAME", "YOUR_API_KEY")
|
|
|
|
|
|
|
|
textMagicService.AddReceivers("Destination1-Phone-Number")
|
2021-05-06 16:53:59 +02:00
|
|
|
|
|
|
|
notifier := notify.New()
|
2021-05-26 11:32:48 +02:00
|
|
|
notifier.UseServices(textMagicService)
|
2021-05-06 16:53:59 +02:00
|
|
|
|
|
|
|
err := notifier.Send(context.Background(), "subject", "message")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("notifier.Send() failed: %s", err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Printf("notification sent")
|
|
|
|
}
|
|
|
|
```
|