Hangup a call after a minute

Schedule a hangup call after a minute while playing a message on the call.

Response

<Response>
    <Hangup schedule="60" reason="rejected" />
    <Speak loop="0">This call will be hung up after a minute</Speak>
</Response>

Example Request

1
2
3
4
5
6
7
from plivo import plivoxml

response = plivoxml.ResponseElement()
response.add(plivoxml.HangupElement(schedule=60, reason='rejected'))
response.add(
    plivoxml.SpeakElement('This call will hang up after a minute.', loop=0))
print(response.to_string())
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
require 'rubygems'
require 'plivo'

include Plivo::XML
include Plivo::Exceptions

begin
  response = Response.new

  params = {
      schedule: '60',
      reason: 'rejected'
  }
  response.addHangup(params)

  speak_params = {
      loop: '0'
  }
  speak_body = 'This call will be hung up after a minute'
  response.addSpeak(speak_body, speak_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
19
20
21
22
23
24
25
var plivo = require('plivo');

var response = plivo.Response();

var params = {
    'schedule': "60",
    'reason': "rejected"
};
response.addHangup(params);

var speak_params = {
    'loop': "0"
};
var speak_body = "This call will be hung up after a minute";
response.addSpeak(speak_body, speak_params);

console.log(response.toXML());

/*
Sample Output
<Response>
    <Hangup schedule="60" reason="rejected"/>
    <Speak loop="0">This call will be hung up after a minute</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
26
27
28
29
30
31
32
<?php
    require '../vendor/autoload.php';
    use Plivo\XML\Response;

    $response = new Response();

    $params = array(
        'schedule' => "60",
        'reason' => "rejected"
    );

    $response->addHangup($params);

    $speak_params = array(
        'loop' => "0"
    );

    $speak_body = "This call will be hung up after a minute";
    $response->addSpeak($speak_body,$speak_params);

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

    /*
    Sample Output

    <Response>
        <Hangup schedule="60" reason="rejected"/>
        <Speak loop="0">This call will be hung up after a minute</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
26
27
// Example for xml - hangup a call after a minute
package com.plivo.api.xml.samples.xml;

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


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


                        new Hangup()
                                .reason("rejected")
                                .schedule(60),


                        new Speak("This call will hang up after a minute.")
                                .loop(0)

                );
        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
29
30
31
32
33
34
35
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.AddHangup(new Dictionary<string, string>()
			{
				{"schedule", "60"},
				{"reason", "rejected" }
			});
			resp.AddSpeak("Call will hangup after a min.",
				new Dictionary<string, string>()
			{
				{"loop", "0"}
			});

			var output = resp.ToString();
			Console.WriteLine(output);

		}
	}
}



//<Response>
//  <Hangup schedule = "60" reason="rejected" />
//  <Speak loop = "0" > Call will hangup after a min.</Speak>
//</Response>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Example for xml - hangup
package main

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

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

			new(xml.HangupElement).
				SetReason("rejected").
				SetSchedule(60),

			new(xml.SpeakElement).
				SetLoop(0).
				SetContents("This call will hang up after a minute."),
		},
	}
	print(response.String())
}