github.com/twilio/twilio-go@v1.20.1/UPGRADE.md (about) 1 # Upgrade Guide 2 3 _All `MAJOR` version bumps will have upgrade notes posted here._ 4 5 [2022-10-05] 0.26.x to 1.x.x 6 ----------------------------- 7 ### NEW FEATURE - Added Support for Twiml Building 8 The twilio-go library now supports building Twiml elements for applications. 9 #### Send a message and redirect with twiml programmable messaging 10 ```go 11 package main 12 13 import ( 14 "fmt" 15 "github.com/twilio/twilio-go/twiml" 16 ) 17 18 func main() { 19 //Create Verbs 20 message := &twiml.MessagingMessage{ 21 To: "+15017122661", 22 From: "+15558675310", 23 OptionalAttributes: map[string]string{"community": "user"}, 24 } 25 redirect := &twiml.MessagingRedirect{ 26 Url: "https://demo.twilio.com/welcome/sms", 27 } 28 29 //Create Noun 30 body := &twiml.MessagingBody{ 31 Message: "Hello World!", 32 } 33 34 //Adding Body element to the Message Verb 35 message.InnerElements = []twiml.Element{body} 36 37 //Adding all Verbs to twiml.Messages 38 verbList := []twiml.Element{message, redirect} 39 twimlResult, err := twiml.Messages(verbList) 40 if err == nil { 41 fmt.Println(twimlResult) 42 } else { 43 fmt.Println(err) 44 } 45 } 46 47 ``` 48 This will output XML that looks like this: 49 ```xml 50 <?xml version="1.0" encoding="UTF-8"?> 51 <Response> 52 <Message to="+15017122661" from="+15558675310" community="user"> 53 <Body>Hello World!</Body> 54 </Message> 55 <Redirect>https://demo.twilio.com/welcome/sms</Redirect> 56 </Response> 57 ``` 58 The following example shows `Gather` with a nested `Say`. This will read some text to the caller, and allows the caller to enter input at any time while that text is read to them. 59 ```go 60 package main 61 62 import ( 63 "fmt" 64 "github.com/twilio/twilio-go/twiml" 65 ) 66 67 func main() { 68 //Create Verbs 69 gather := &twiml.VoiceGather{ 70 Input: "speech dtmf", 71 Timeout: "2", 72 NumDigits: "1", 73 } 74 say := &twiml.VoiceSay{ 75 Message: "Please press 1 or say sales for sales.", 76 } 77 78 //Adding Say element to Gather 79 gather.InnerElements = []twiml.Element{say} 80 81 //Adding all Verbs to twiml.Voice 82 verbList := []twiml.Element{gather} 83 twimlResult, err := twiml.Voice(verbList) 84 if err == nil { 85 fmt.Println(twimlResult) 86 } else { 87 fmt.Println(err) 88 } 89 } 90 ``` 91 This will output XML that looks like this: 92 ```xml 93 <?xml version="1.0" encoding="UTF-8"?> 94 <Response> 95 <Gather input="speech dtmf" timeout="2" numDigits="1"> 96 <Say>Please press 1 or say sales for sales.</Say> 97 </Gather> 98 </Response> 99 ``` 100 ### NEW VERSION - Added support for version 1.19 of Go 101 ### FIXED - Fixed request validator key sorting logic and added support for validating x-www-form-urlencoded requests. 102 The twilio-go library now supports validating x-www-form-urlencoded requests and has fixed the key sorting logic for validating requests. 103 Checkout the [PR](https://github.com/twilio/twilio-go/pull/173) for more details. 104 105 [2022-05-18] 0.25.x to 0.26.x 106 ----------------------------- 107 ### CHANGED - Renamed ApiV2010 to Api. 108 ApiV2010 has now been renamed to Api. This has caused a breaking change for all endpoints located under `rest/api/2010`. 109 110 #### Send a SMS 111 ```go 112 //0.2.x 113 client := twilio.NewRestClient() 114 115 params := &api.CreateMessageParams{} 116 params.SetFrom("+15017122661") 117 params.SetBody("body") 118 params.SetTo("+15558675310") 119 120 resp, err := client.ApiV2010.CreateMessage(params) 121 ``` 122 ```go 123 //1.x.xrc 124 client := twilio.NewRestClient() 125 126 params := &api.CreateMessageParams{} 127 params.SetFrom("+15017122661") 128 params.SetBody("body") 129 params.SetTo("+15558675310") 130 131 resp, err := client.Api.CreateMessage(params) 132 ```