Play in a Loop

This XML example tells Plivo to say “Wow” thrice in a row.

Response

<Response>
    <Speak loop="3">Wow</Speak>
</Response>

Example Request

1
2
3
4
5
from plivo import plivoxml

response = (plivoxml.ResponseElement()
            .add(plivoxml.SpeakElement('Wow.').set_loop(3)))
print(response.to_string())
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'rubygems'
require 'plivo'

include Plivo::XML
include Plivo::Exceptions

begin
  response = Response.new

  speak_body = 'Wow'
  params = {
    loop: '3'
  }
  response.addSpeak(speak_body, params)

  xml = PlivoXML.new(response)
  puts xml.to_xml
rescue PlivoXMLError => e
  puts 'Exception: ' + e.message
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var plivo = require('plivo');

var response = plivo.Response();

var speak_body = "Wow";
var params = {
        'loop': "3"
};
response.addSpeak(speak_body, params);

console.log(response.toXML());

/*
Sample Output
<Response>
    <Speak loop="3">Wow</Speak>
</Response>
*/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
    require '../vendor/autoload.php';
    use Plivo\XML\Response;

    $response = new Response();

    $speak_body = "Wow";

    $params = array(
        'loop' => "3"
    );

    $response->addSpeak($speak_body, $params);

    Header('Content-type: text/xml');
    echo($response->toXML());

    /*
    Sample Output

    <Response>
        <Speak loop="3">Wow</Speak>
    </Response>
    */
?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Example for speak - play in a loop
package com.plivo.api.xml.samples.speak;

import com.plivo.api.exceptions.PlivoXmlException;
import com.plivo.api.xml.Response;
import com.plivo.api.xml.Speak;


class PlayInALoop {
    public static void main(String[] args) throws PlivoXmlException {
        Response response = new Response()
                .children(


                        new Speak("Wow.")
                                .loop(3)

                );
        System.out.println(response.toXmlString());
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
using Plivo.XML;

namespace Plivo
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			Plivo.XML.Response resp = new Plivo.XML.Response();
			resp.AddSpeak("Go green, go plivo.", 
             new Dictionary<string, string>()
			{
				{"loop", "3"}
			});
			var output = resp.ToString();
			Console.WriteLine(output);

		}
	}
}



//<Response>
//  <Speak loop = "3" > Go green, go plivo.</Speak>
//</Response>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Example for speak - play in loop
package main

import "github.com/plivo/plivo-go/xml"

func main() {
	response := xml.ResponseElement{
		Contents: []interface{}{

			new(xml.SpeakElement).
				SetLoop(3).
				SetContents("Wow."),
		},
	}
	print(response.String())
}