Help us shape the future of Go! Take the 2026 Go Developer Survey

twilio

package module
v0.0.0-...-b26f757 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2018 License: MIT Imports: 5 Imported by: 0

README

Twilio

Very basic golang client for sending Twilio SMS Messages. Also includes a notify-me command for sending messages from the command easily.

Warning: No stable API at this time. Use at own risk.

Usage


client := twilio.NewClient(twilio.APIBase, "ACCOUNT_SID", "AUTH_TOKEN")
msg := &twilio.Message{
        To: "+11234567890"),
        From: "+11234567890",
        Body: "My Message",
}

err := client.SendMessage(msg)

Commands

notify-me

Ever run a long job out on a server and would appreciate a text when it has completed successfully? Want something simple? Just compile this simple go program with your Account SID, Auth Token, and your from twilio number like so:

TWILIO_ACCOUNT_SID="3264b903d3CA97362d72b3ebd7ebb797f1" TWILIO_AUTH_TOKEN="b9a149888773e1dacfe503bebbde3bda" TWILIO_FROM_NUMBER="+18186984622" make install

and you can do things like:

$ some-long-running-command && notify-me "+11234567890" "It worked\!" || notify-me "+11234567890" "It failed\!"

Documentation

Index

Constants

View Source
const (
	APIBase = "https://api.twilio.com"
)

API constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Twilio client

func NewClient

func NewClient(baseURL, accountSID, authToken string) *Client

NewClient initializes and returns a new client.

func (*Client) SendMessage

func (c *Client) SendMessage(msg *Message) error

SendMessage sends the given message

type Message

type Message struct {
	To       string
	From     string
	Body     string
	MediaURL string
}

Message is a SMS Message

Directories

Path Synopsis
cmd
notify-me command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL