This repository was archived by the owner on Aug 15, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +33
-24
lines changed
rest/taskrouter/twiml/example2/example Expand file tree Collapse file tree 6 files changed +33
-24
lines changed Original file line number Diff line number Diff line change 11<?php
22// Download the library and copy into the folder containing this file.
3- require ( ' twilio-php/ Services/Twilio.php ') ;
3+ require_once ' /path/to/vendor/ twilio/sdk/ Services/Twilio.php ' ;
44
55$ response = new Services_Twilio_Twiml ;
6- $ response ->enqueue (array (workflowSid => 'WW0123456789abcdef0123456789abcdef ' ))
7- ->task ("{'account_number':'12345abcdef'} " );
6+ $ response ->enqueue (array (' workflowSid ' => 'WW0123456789abcdef0123456789abcdef ' ))
7+ ->task ("{'account_number':'12345abcdef'} " );
88print $ response ;
99?>
10-
1110<!-- alternatively -->
1211
1312<?php
2120 <Enqueue workflowSid="<?php echo $ workflowSid ?> ">
2221 <Task>{"account_number": "12345abcdef"}</Task>
2322 </Enqueue>
24- </Response>
23+ </Response>
Original file line number Diff line number Diff line change 33using System ;
44using System . Net ;
55using Twilio . TwiML ;
6+ using Twilio . TwiML . Voice ;
67
78class Example
89{
9- public static HttpListenerResponse SendResponse ( HttpListenerContext ctx )
10+ public static void SendResponse ( HttpListenerContext ctx )
1011 {
1112 HttpListenerRequest request = ctx . Request ;
1213 HttpListenerResponse response = ctx . Response ;
1314
1415 response . StatusCode = ( int ) HttpStatusCode . OK ;
1516 response . ContentType = "text/xml" ;
1617
18+ // Generate TwiML
1719 var twiml = new VoiceResponse ( ) ;
18- twiml . Enqueue ( "{\" account_number\" :\" 12345abcdef\" }" ,
19- workflowSid : "WW0123456789abcdef0123456789abcdef" ) ;
20+ var enqueue = new Enqueue ( workflowSid : "WW0123456789abcdef0123456789abcdef" ) ;
21+ enqueue . Task ( "{\" account_number\" : \" 12345abcdef\" }" ) ;
22+ twiml . Append ( enqueue ) ;
2023
21- response . StatusDescription = twiml . ToString ( ) ;
22- return response ;
24+ // Write the output and close the stream
25+ byte [ ] buffer = Encoding . UTF8 . GetBytes ( twiml . ToString ( ) ) ;
26+ response . ContentLength64 = buffer . Length ;
27+ response . OutputStream . Write ( buffer , 0 , buffer . Length ) ;
28+ response . OutputStream . Close ( ) ;
2329 }
2430}
Original file line number Diff line number Diff line change 55set :port , 8080
66
77post '/enqueue_call' do
8- attributes = '{"account_number":"12345abcdef"}'
98
10- Twilio ::TwiML ::Response . new do |r |
11- r . Enqueue workflowSid : 'WW0123456789abcdef0123456789abcdef' do |e |
12- e . Task attributes
9+ attributes = '{"account_number": "12345abcdef"}'
10+
11+ Twilio ::TwiML ::VoiceResponse . new do |response |
12+ response . enqueue ( workflowSid : 'WW0123456789abcdef0123456789abcdef' ) do |e |
13+ e . task ( attributes )
1314 end
14- end . text
15+ end . to_s
1516end
Original file line number Diff line number Diff line change 11# Download the Python helper library from twilio.com/docs/python/install
22from flask import Flask
3- from twilio .twiml .voice_response import VoiceResponse
3+ from twilio .twiml .voice_response import VoiceResponse , Enqueue
44
55app = Flask (__name__ )
66
77
88@app .route ("/enqueue_call" , methods = ['GET' , 'POST' ])
99def enqueue_call ():
10- # workflow_sid = 'WW0123456789abcdef0123456789abcdef'
10+
11+ workflow_sid = 'WW0123456789abcdef0123456789abcdef'
1112
1213 resp = VoiceResponse ()
13- # TODO waiting for https://github.com/twilio/twilio-python/issues/283
1414
15- # with resp.enqueue(None, workflowSid=workflow_sid) as e:
16- # e.task('{"account_number":"12345abcdef"}')
15+ e = Enqueue (None , workflowSid = workflow_sid )
16+ e .task ('{"account_number":"12345abcdef"}' )
17+
18+ resp .append (e )
1719
1820 return str (resp )
Original file line number Diff line number Diff line change 66import javax .servlet .http .HttpServletResponse ;
77
88import com .twilio .twiml .voice .Enqueue ;
9- import com .twilio .twiml .Task ;
9+ import com .twilio .twiml .voice . Task ;
1010import com .twilio .twiml .TwiMLException ;
1111import com .twilio .twiml .VoiceResponse ;
1212
@@ -15,7 +15,8 @@ public class Example extends HttpServlet {
1515
1616 @ Override
1717 public void service (HttpServletRequest request , HttpServletResponse response ) throws IOException {
18- Task task = new Task .Builder ().data ("{\" account_number\" :\" 12345abcdef\" }" ).build ();
18+
19+ Task task = new Task .Builder ("{\" account_number\" :\" 12345abcdef\" }" ).build ();
1920
2021 Enqueue enqueue =
2122 new Enqueue .Builder ()
Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" UTF-8" ?>
22<Response >
3- <Enqueue workflowSid =" WW0123456789abcdef0123456789abcdef" / >
3+ <Enqueue workflowSid =" WW0123456789abcdef0123456789abcdef" >
44 <Task >{"account_number": "12345abcdef"}</Task >
55 </Enqueue >
6- </Response >
6+ </Response >
You can’t perform that action at this time.
0 commit comments