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 1
1
<?php
2
2
// 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 ' ;
4
4
5
5
$ 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'} " );
8
8
print $ response ;
9
9
?>
10
-
11
10
<!-- alternatively -->
12
11
13
12
<?php
21
20
<Enqueue workflowSid="<?php echo $ workflowSid ?> ">
22
21
<Task>{"account_number": "12345abcdef"}</Task>
23
22
</Enqueue>
24
- </Response>
23
+ </Response>
Original file line number Diff line number Diff line change 3
3
using System ;
4
4
using System . Net ;
5
5
using Twilio . TwiML ;
6
+ using Twilio . TwiML . Voice ;
6
7
7
8
class Example
8
9
{
9
- public static HttpListenerResponse SendResponse ( HttpListenerContext ctx )
10
+ public static void SendResponse ( HttpListenerContext ctx )
10
11
{
11
12
HttpListenerRequest request = ctx . Request ;
12
13
HttpListenerResponse response = ctx . Response ;
13
14
14
15
response . StatusCode = ( int ) HttpStatusCode . OK ;
15
16
response . ContentType = "text/xml" ;
16
17
18
+ // Generate TwiML
17
19
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 ) ;
20
23
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 ( ) ;
23
29
}
24
30
}
Original file line number Diff line number Diff line change 5
5
set :port , 8080
6
6
7
7
post '/enqueue_call' do
8
- attributes = '{"account_number":"12345abcdef"}'
9
8
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 )
13
14
end
14
- end . text
15
+ end . to_s
15
16
end
Original file line number Diff line number Diff line change 1
1
# Download the Python helper library from twilio.com/docs/python/install
2
2
from flask import Flask
3
- from twilio .twiml .voice_response import VoiceResponse
3
+ from twilio .twiml .voice_response import VoiceResponse , Enqueue
4
4
5
5
app = Flask (__name__ )
6
6
7
7
8
8
@app .route ("/enqueue_call" , methods = ['GET' , 'POST' ])
9
9
def enqueue_call ():
10
- # workflow_sid = 'WW0123456789abcdef0123456789abcdef'
10
+
11
+ workflow_sid = 'WW0123456789abcdef0123456789abcdef'
11
12
12
13
resp = VoiceResponse ()
13
- # TODO waiting for https://github.com/twilio/twilio-python/issues/283
14
14
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 )
17
19
18
20
return str (resp )
Original file line number Diff line number Diff line change 6
6
import javax .servlet .http .HttpServletResponse ;
7
7
8
8
import com .twilio .twiml .voice .Enqueue ;
9
- import com .twilio .twiml .Task ;
9
+ import com .twilio .twiml .voice . Task ;
10
10
import com .twilio .twiml .TwiMLException ;
11
11
import com .twilio .twiml .VoiceResponse ;
12
12
@@ -15,7 +15,8 @@ public class Example extends HttpServlet {
15
15
16
16
@ Override
17
17
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 ();
19
20
20
21
Enqueue enqueue =
21
22
new Enqueue .Builder ()
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
2
<Response >
3
- <Enqueue workflowSid =" WW0123456789abcdef0123456789abcdef" / >
3
+ <Enqueue workflowSid =" WW0123456789abcdef0123456789abcdef" >
4
4
<Task >{"account_number": "12345abcdef"}</Task >
5
5
</Enqueue >
6
- </Response >
6
+ </Response >
You can’t perform that action at this time.
0 commit comments