Skip to content

Latest commit

 

History

History

plivo

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Plivo

go.dev reference

Prerequisites

You will need to have a Plivo account and the following things:

  1. Auth ID and Auth Token from Plivo console.
  2. 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")
}