Skip to content

Commit b66b637

Browse files
authored
Merge pull request #11 from settermjd/add-go-code-samples
Add Go examples to the repository
2 parents f11a9ca + 62e90a0 commit b66b637

File tree

117 files changed

+2733
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+2733
-3
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/twilio/twilio-go/twiml"
7+
)
8+
9+
func main() {
10+
twiml, _ := twiml.Messages([]twiml.Element{
11+
&twiml.MessagingMessage{
12+
Body: "Store Location: 123 Easy St.",
13+
},
14+
})
15+
16+
fmt.Print(twiml)
17+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/twilio/twilio-go/twiml"
7+
)
8+
9+
func main() {
10+
twiml, _ := twiml.Messages([]twiml.Element{
11+
&twiml.MessagingMessage{
12+
InnerElements: []twiml.Element{
13+
&twiml.MessagingBody{
14+
Message: "Store Location: 123 Easy St.",
15+
},
16+
&twiml.MessagingMedia{
17+
Url: "https://demo.twilio.com/owl.png",
18+
},
19+
},
20+
},
21+
})
22+
23+
fmt.Print(twiml)
24+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/twilio/twilio-go/twiml"
7+
)
8+
9+
func main() {
10+
twiml, _ := twiml.Messages([]twiml.Element{
11+
&twiml.MessagingMessage{
12+
Action: "/SmsHandler.php",
13+
Body: "Store Location: 123 Easy St.",
14+
Method: "POST",
15+
},
16+
})
17+
18+
fmt.Print(twiml)
19+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/twilio/twilio-go/twiml"
7+
)
8+
9+
func main() {
10+
twiml, _ := twiml.Messages([]twiml.Element{
11+
&twiml.MessagingMessage{
12+
InnerElements: []twiml.Element{
13+
&twiml.MessagingBody{
14+
Message: "Hello friend",
15+
},
16+
&twiml.MessagingMedia{
17+
Url: "https://demo.twilio.com/owl.png",
18+
},
19+
},
20+
},
21+
})
22+
23+
fmt.Print(twiml)
24+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/twilio/twilio-go/twiml"
7+
)
8+
9+
func main() {
10+
twiml, _ := twiml.Messages([]twiml.Element{
11+
&twiml.MessagingRedirect{
12+
Url: "http://www.example.com/nextInstructions",
13+
},
14+
})
15+
16+
fmt.Print(twiml)
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/twilio/twilio-go/twiml"
7+
)
8+
9+
func main() {
10+
twiml, _ := twiml.Messages([]twiml.Element{
11+
&twiml.MessagingRedirect{
12+
Url: "../nextInstructions",
13+
},
14+
})
15+
16+
fmt.Print(twiml)
17+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/twilio/twilio-go/twiml"
7+
)
8+
9+
func main() {
10+
twiml, _ := twiml.Messages([]twiml.Element{
11+
&twiml.MessagingMessage{
12+
InnerElements: []twiml.Element{
13+
&twiml.MessagingBody{
14+
Message: "Hello World!",
15+
},
16+
},
17+
},
18+
&twiml.MessagingRedirect{
19+
Url: "https://demo.twilio.com/welcome/sms/",
20+
},
21+
})
22+
23+
fmt.Print(twiml)
24+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/twilio/twilio-go/twiml"
7+
)
8+
9+
func main() {
10+
twiml, _ := twiml.Messages([]twiml.Element{
11+
&twiml.MessagingMessage{
12+
Body: "This is message 1 of 2.",
13+
},
14+
&twiml.MessagingMessage{
15+
Body: "This is message 2 of 2.",
16+
},
17+
})
18+
19+
fmt.Print(twiml)
20+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/twilio/twilio-go/twiml"
7+
)
8+
9+
func main() {
10+
twiml, _ := twiml.Voice([]twiml.Element{
11+
&twiml.VoiceDial{
12+
InnerElements: []twiml.Element{
13+
&twiml.VoiceApplication{
14+
InnerElements: []twiml.Element{
15+
&twiml.VoiceApplicationSid{
16+
Sid: "AP1234567890abcdef1234567890abcd",
17+
},
18+
},
19+
},
20+
},
21+
},
22+
})
23+
24+
fmt.Print(twiml)
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/twilio/twilio-go/twiml"
7+
)
8+
9+
func main() {
10+
twiml, _ := twiml.Voice([]twiml.Element{
11+
&twiml.VoiceDial{
12+
InnerElements: []twiml.Element{
13+
&twiml.VoiceApplication{
14+
CopyParentTo: "true",
15+
InnerElements: []twiml.Element{
16+
&twiml.VoiceApplicationSid{
17+
Sid: "AP1234567890abcdef1234567890abcd",
18+
},
19+
},
20+
},
21+
},
22+
},
23+
})
24+
25+
fmt.Print(twiml)
26+
}

0 commit comments

Comments
 (0)