twilio

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2023 License: MIT Imports: 8 Imported by: 0

README

Twilio Examples in Go

Build Status Go Report Card Docs License

Various pieces of example code using Twilio.

Documentation

Index

Constants

View Source
const (
	EventConnected = "connected"
	EventStart     = "start"
	EventMedia     = "media"
	EventStop      = "stop"
	EventMark      = "mark"
)
View Source
const (
	TwilioAPICallsJSONURLFormat = `https://api.twilio.com/2010-04-01/Accounts/%s/Calls.json`
)

Variables

This section is empty.

Functions

func BuildTwilioCallURL

func BuildTwilioCallURL(accountSid string) string

func MakeCall

func MakeCall(client *http.Client, apiURL string, opts TwilioCallsOpts) (*http.Response, error)

func TwimlResponseProcess

func TwimlResponseProcess(w http.ResponseWriter, r *http.Request, res *twiml.Response)

Types

type GatherEvent

type GatherEvent struct {
	AccountSid    string
	ApiVersion    string
	Called        string
	CalledCity    string
	CalledCountry string
	Caller        string
	CallerCity    string
	CallerCountry string
	CallerState   string
	CallerZip     string
	CallStatus    string
	Digits        string
	FinishedOnKey string
	From          string
	FromCity      string
	FromState     string
	FromZip       string
	ToCity        string
	ToCountry     string
	ToState       string
	ToZip         string
	// contains filtered or unexported fields
}

type Start

type Start struct {
	XMLName  xml.Name       `xml:"Start"`
	Children []twiml.Markup `xml:",omitempty"`
}

Start TwiML

func (*Start) Type

func (s *Start) Type() string

Type returns the XML name of the verb

func (*Start) Validate

func (s *Start) Validate() error

Validate returns an error if the TwiML is constructed improperly

type Stream

type Stream struct {
	XMLName xml.Name `xml:"Stream"`
	URL     string   `xml:"url,attr,omitempty"`
}

Stream TwiML

func (*Stream) Type

func (s *Stream) Type() string

Type returns the XML name of the verb

func (*Stream) Validate

func (s *Stream) Validate() error

Validate returns an error if the TwiML is constructed improperly

type StreamMessage

type StreamMessage struct {
	Event          string             `json:"event"`
	Mark           StreamMessageMark  `json:"mark,omitempty"`
	Media          StreamMessageMedia `json:"media,omitempty"`
	Protocol       string             `json:"protocol,omitempty"`
	SequenceNumber string             `json:"sequenceNumber"`
	Start          StreamMessageStart `json:"start,omitempty"`
	StreamSid      string             `json:"streamSid"`
	Stop           StreamMessageStop  `json:"stop,omitempty"`
	Version        string             `json:"version,omitempty"`
}

StreamMessage is defined in https://www.twilio.com/docs/voice/twiml/stream

type StreamMessageMark

type StreamMessageMark struct {
	Name string `json:"name"`
}

StreamMessageMark is the property of a `mark` message. The `mark` event is sent only during bi-directional streaming by using the `<Connect>` verb. It is used to track, or label, when media has completed.

type StreamMessageMedia

type StreamMessageMedia struct {
	Track     string `json:"track"`
	Chunk     string `json:"chunk"`
	Timestamp string `json:"timestamp"`
	Payload   string `json:"payload"`
}

StreamMessageMedia is a property of a media message. This message type encapsulates the raw audio data.

type StreamMessageStart

type StreamMessageStart struct {
	AccountSid       string            `json:"accountSid"`
	CallSid          string            `json:"callSid"`
	StreamSid        string            `json:"streamSid"`
	Tracks           []string          `json:"tracks"`
	CustomParameters map[string]string `json:"customParameters"`
}

StreamMessageStart is a property of a start message. This message contains important metadata about the stream and is sent immediately after the Connected message. It is only sent once at the start of the Stream.

type StreamMessageStop

type StreamMessageStop struct {
	AccountSid string `json:"accountSid"`
	CallSid    string `json:"callSid"`
}

StreamMessageStop is a property of a stop message. A stop message will be sent when the Stream is either `<Stop>`ped or the Call has ended.

type TwilioCallsOpts

type TwilioCallsOpts struct {
	To          string `url:"To"`
	From        string `url:"From"`
	CallbackURL string `url:"Url"`
}

func (*TwilioCallsOpts) MustString

func (opts *TwilioCallsOpts) MustString() string

func (*TwilioCallsOpts) StringsReader

func (opts *TwilioCallsOpts) StringsReader() *strings.Reader

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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