Documentation ¶
Overview ¶
Package twilio is s small wrapper to be used with the Twilio API. Twilio lets you use standard web languages to build voice, VoIP and SMS applications via a web API.
To use it, all that you need is to create a client:
client := NewTwilioRestClient("yourAccount", "yourToken")
And to send a message just write:
client.Messages.Create("fromNumber", "toNumber", "body")
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Calls ¶
type Calls struct {
// contains filtered or unexported fields
}
Calls is an intermediate class that for now is here just to emulate the Python API behaviour
func (*Calls) Create ¶
func (c *Calls) Create(from string, to string, URL string) (*CallsResponse, *ErrorResponse)
Create a new call. You will need an external XML endpoint with the TwiML XML
type CallsResponse ¶
type CallsResponse struct { Sid string DateCreated string `json:"date_created"` DateUpdated string `json:"date_updated"` ParentCallSid string `json:"parent_call_sid"` AccountSid string `json:"account_sid"` To string ToFormated string `json:"to_formatted"` From string FromFormatted string `json:"from_formatted"` PhoneNumberSid string `json:"phone_number_sid"` Status string StartTime string `json:"start_time"` EndTime string `json:"end_time"` Duration string Price string PriceUnit string `json:"price_unit"` Direction string AnsweredBy string `json:"answered_by"` APIVersion string `json:"api_version"` Annotation string ForwardedFrom string `json:"forwaded_from"` GroupSid string `json:"group_sid"` CallerName string `json:"caller_name"` Uri string SubresourceUris struct { Notifications string Recordings string } `json:"subresource_uris"` }
CallsResponse is the struct where we will Unmarshal the API response
type ErrorResponse ¶
ErrorResponse is the global struct that we are going to use to unmarshall the errors returned by the API
func NewErrorResponse ¶
func NewErrorResponse(body io.Reader) *ErrorResponse
NewErrorResponse will create an object type ErrorResponse giving the body passed as parameter
type Messages ¶
type Messages struct {
// contains filtered or unexported fields
}
Messages is an intermediate class that will allow the creation of lists of recipients/messages
func (*Messages) Create ¶
func (m *Messages) Create(from string, to string, body string) (*MessagesResponse, *ErrorResponse)
Create a new SMS
type MessagesResponse ¶
type MessagesResponse struct { AccountSid string `json:"account_sid"` APIVersion string `json:"api_version"` Body string NumSegments string `json:"num_segments"` NumMedia string `json:"num_media"` DateCreated string `json:"date_created"` DateSent string `json:"date_sent"` DateUpdated string `json:"date_updated"` Direciton string From string Prices string Sid string Status string To string Uri string }
MessagesResponse is the struct where we will Unmarshal the API response
type TwilioRestClient ¶
type TwilioRestClient struct { Calls *Calls Messages *Messages // contains filtered or unexported fields }
TwilioRestClient is an struct to store your Twilio credentials and available methods
func NewTwilioRestClient ¶
func NewTwilioRestClient(account string, token string) *TwilioRestClient
NewTwilioRestClient is going to create a new Twilio client providing the account and token details
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
sms
This example is showing how to create a command to send SMS using the Twilio API in a really easy way.
|
This example is showing how to create a command to send SMS using the Twilio API in a really easy way. |
voice
This example is going to make a call using the Twilio API.
|
This example is going to make a call using the Twilio API. |