mirror of
https://github.com/nikoksr/notify.git
synced 2024-11-24 08:22:18 +02:00
1.2 KiB
1.2 KiB
Plivo
Prerequisites
You will need to have a Plivo account and the following things:
Auth ID
andAuth Token
from Plivo console.- An active rented Plivo phone number.
Usage
package main
import (
"context"
"log"
"github.com/nikoksr/notify"
"github.com/nikoksr/notify/service/plivo"
)
func main() {
plivoSvc, err := plivo.New(
&plivo.ClientOptions{
AuthID: "<Your-Plivo-Auth-Id>",
AuthToken: "<Your-Plivo-Auth-Token>",
}, &plivo.MessageOptions{
Source: "<Your-Plivo-Source-Number>",
})
if err != nil {
log.Fatalf("plivo.New() failed: %s", err.Error())
}
plivoSvc.AddReceivers("Destination1")
notifier := notify.New()
notifier.UseServices(plivoSvc)
err = notifier.Send(context.Background(), "subject", "message")
if err != nil {
log.Fatalf("notifier.Send() failed: %s", err.Error())
}
log.Printf("notification sent")
}