Skip to content

dedwardstech/twilio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twilio

This package just contains methods for Twilio SMS currently. Feel free to submit PRs for other Twilio products. Also feel free to submit suggestions!

SMS

The SMS package contains 4 important structs.

Client

The Client struct is responsible for building requests for a particular account/number combination.

Creating a new client

client, err := sms.NewClient(&sms.ClientOptions{
    AccountSid: "xxxxxx",
    AuthToken: "xxxxxx",
    Number: "+18008675309"
})

The client does not send SMS messages. It exists purely to build the http Requests. Sending is delegated back to the consumer.

Building a request

msgReq, err := client.NewRequest("+18009999999", "Hello World")
if err != nil {
	// handle error
}

httpClient := &http.Client{}
resp, err := httpClient.Do(msgReq)
if err != nil {
	// handle http error
}
...
Parser

The parser is responsible for parsing incoming Twilio messages from a Twilio webhook.

Creating a new parser

parser := sms.NewMessageParser()
msg := parser.FromRequest(r)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published