Skip to content
No description, website, or topics provided.
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
accounts
applications
common Exporting BaseURL so tests in other modules can change it Aug 5, 2014
conference adding filter for participant list Jul 26, 2014
examples
notifications
numbers
queues fixing conflict Sep 9, 2014
recording
sip
sms fix check_apps example Sep 8, 2014
transcription renaming to ResourceInfo Jul 22, 2014
twiml
usage renaming to ResourceInfo Jul 22, 2014
voice
.gitignore satisfying golint Jul 10, 2014
.travis.yml updating travis config Sep 15, 2014
NOTES.md
README.md expanding README Jul 21, 2014
account.go
account_test.go

README.md

Twilio Go

alt text Build Status

Write Twilio applications with our Go helper library. To get started, there are some example applications in the examples folder.

All Twilio API calls are validated at runtime to insure that all necesary information is provided.

You can generate a callback parser for all Twilio callbacks that will publish the parsed callbacks into a channel. See the SMS example below for an example of how this works.

Installation

go get github.com/natebrennand/twiliogo

Usage

Linking your account(s)

You can manage your credentials either through environment variables or manually setting them. The library will panic if you attempt to input an invalid AccountSid or token.

Environment Variables

export TWILIO_ACCOUNT="accountsid"
export TWILIO_TOKEN="accounttoken"
act := twilogo.NewAccountFromEnv()

Manual Setting

act := twiliogo.NewAccount("AccountSid", "AccountToken")

Making a call

act := twilogo.NewAccountFromEnv()

resp, err := act.Voice.Call(voice.Post{
	From: "+{ Your Twilio Number }",
	To:   "+{ Your Destination Number }",
	URL:  "http://twimlbin.com/mytwiml",
})

Sending a text - with a callback handler

act := twilogo.NewAccountFromEnv()

resp, err := act.Sms.Send(sms.Post{
	From:           "+{ Your Twilio Number }",
	To:             "+{ Your Destination Number }",
	Body:           "Ready to become a Go-ru?",
	StatusCallback: "{ Your IP/DNS }/sms_callback",
})

smsChan := make(chan sms.Callback)
go func(callbackChan chan sms.Callback){
	for {
		smsCallback <- callbackChan
		// process smsCallback as desired
	}
}()

// Register the sms callback handler
// All incoming SMS callbacks will be parsed and sent into "smsChan"
http.Handle("/sms_callback", sms.CallbackHandler(smsChan))

http.ListenAndServe("0.0.0.0:8000", nil)
You can’t perform that action at this time.