Documentation
¶
Overview ¶
Package twilio contains helpers for building Twilio applications.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Clock = clockwork.NewRealClock()
Clock provides time for calculating expiry times in tokens.
Functions ¶
func Generate ¶
func Generate(c Capabilities, expires time.Duration) (string, error)
Generate creates a Capabilities Token given some configuration values. See https://www.twilio.com/docs/api/client/capability-tokens for details.
Example ¶
package main
import (
"fmt"
"time"
"github.com/jonboulle/clockwork"
"github.com/tmc/twilio"
)
func init() {
twilio.Clock = clockwork.NewFakeClockAt(time.Unix(1257894000, 0))
}
func main() {
caps := twilio.Capabilities{
AccountSid: "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
AuthToken: "yyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
AllowClientIncoming: "tommy",
AllowClientOutgoing: "APFOOOOOOOo",
}
token, err := twilio.Generate(caps, time.Second)
if err != nil {
panic(err)
}
fmt.Println(token)
}
Output: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjEyNTc4OTQwMDEsImlzcyI6IkFDeHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHgiLCJzY29wZSI6InNjb3BlOmNsaWVudDpvdXRnb2luZz9hcHBTaWQ9QVBGT09PT09PT29cdTAwMjZjbGllbnROYW1lPXRvbW15IHNjb3BlOmNsaWVudDppbmNvbWluZz9jbGllbnROYW1lPXRvbW15In0.n-GADTApMTBanP_o69br2djf8GSmycaL3FpLYHHcrTA
Types ¶
type Capabilities ¶
type Capabilities struct {
AccountSid string // AccountSid is the Twilio Account Sid
AuthToken string // AuthToken is the secret Twilio Account Auth Token
AllowClientIncoming string // AllowClientIncoming specifies the possible client name that can be adopted
AllowClientOutgoing string // AllowClientOutgoing specifies that this token can make outgoing calls using the given Application Sid
}
Capabilities describes the possible capabilities for a Twilio token.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package twiml provides Twilio Markup Language support for building web services with instructions for twilio how to handle incoming call or message.
|
Package twiml provides Twilio Markup Language support for building web services with instructions for twilio how to handle incoming call or message. |
|
Package twirest provides a interface to Twilio REST API allowing the user to query meta-data from their account and, to initiate calls and send SMS.
|
Package twirest provides a interface to Twilio REST API allowing the user to query meta-data from their account and, to initiate calls and send SMS. |