Schedule a hangup call after a minute while playing a message on the call.
Response
<Response><Hangupschedule="60"reason="rejected"/><Speakloop="0">This call will be hung up after a minute</Speak></Response>
Example Request
1
2
3
4
5
6
7
fromplivoimportplivoxmlresponse=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())
require'rubygems'require'plivo'includePlivo::XMLincludePlivo::Exceptionsbeginresponse=Response.newparams={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)putsxml.to_xmlrescuePlivoXMLError=>eputs'Exception: '+e.messageend
varplivo=require('plivo');varresponse=plivo.Response();varparams={'schedule':"60",'reason':"rejected"};response.addHangup(params);varspeak_params={'loop':"0"};varspeak_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>
*/
<?phprequire'../vendor/autoload.php';usePlivo\XML\Response;$response=newResponse();$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>
*/?>
// Example for xml - hangup a call after a minutepackagecom.plivo.api.xml.samples.xml;importcom.plivo.api.exceptions.PlivoXmlException;importcom.plivo.api.xml.Hangup;importcom.plivo.api.xml.Response;importcom.plivo.api.xml.Speak;classHangupACallAfterAMinute{publicstaticvoidmain(String[]args)throwsPlivoXmlException{Responseresponse=newResponse().children(newHangup().reason("rejected").schedule(60),newSpeak("This call will hang up after a minute.").loop(0));System.out.println(response.toXmlString());}}
usingSystem;usingSystem.Collections.Generic;usingPlivo.XML;namespacePlivo{classMainClass{publicstaticvoidMain(string[]args){Plivo.XML.Responseresp=newPlivo.XML.Response();resp.AddHangup(newDictionary<string,string>(){{"schedule","60"},{"reason","rejected"}});resp.AddSpeak("Call will hangup after a min.",newDictionary<string,string>(){{"loop","0"}});varoutput=resp.ToString();Console.WriteLine(output);}}}//<Response>// <Hangup schedule = "60" reason="rejected" />// <Speak loop = "0" > Call will hangup after a min.</Speak>//</Response>
// Example for xml - hanguppackagemainimport"github.com/plivo/plivo-go/xml"funcmain(){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())}
fromflaskimportFlask,Response,requestimportplivoxmlapp=Flask(__name__)@app.route('/hangup/',methods=['GET','POST'])defhangup():response=plivoxml.Response()params={'schedule':"60",'reason':"rejected"}response.addHangup(**params)params2={'loop':"0"}response.addSpeak("This call will hang up after a minute.",**params2)returnResponse(str(response),mimetype='text/xml')if__name__=="__main__":app.run(host='0.0.0.0',debug=True)# Sample Conference XML
# <Response>
# <Hangup reason="rejected" schedule="60"/>
# <Speak loop="0">
# This call will hang up after a minute.
# </Speak>
# </Response>
require'rubygems'require'plivo'includePlivoresponse=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)putsresponse.to_xml()=begin
Sample Output
<Response>
<Hangup reason='rejected' schedule='60'/>
<Speak loop='0'>
This call will be hung up after a minute
</Speak>
</Response>
=end
varplivo=require('plivo');varresponse=plivo.Response();varparams={'schedule':"60",'reason':"rejected"};response.addHangup(params);varspeak_params={'loop':"0"};varspeak_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>
*/
<?phprequire'../vendor/autoload.php';usePlivo\Response;$response=newResponse();$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>
*/?>
importjava.io.IOException;importcom.plivo.helper.exception.PlivoException;importcom.plivo.helper.xml.elements.Hangup;importcom.plivo.helper.xml.elements.PlivoResponse;importcom.plivo.helper.xml.elements.Speak;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importorg.eclipse.jetty.server.Server;importorg.eclipse.jetty.servlet.ServletContextHandler;importorg.eclipse.jetty.servlet.ServletHolder;publicclasshangupextendsHttpServlet{privatestaticfinallongserialVersionUID=1L;@OverrideprotectedvoiddoGet(HttpServletRequestreq,HttpServletResponseresp)throwsServletException,IOException{PlivoResponseresponse=newPlivoResponse();Hanguphangup=newHangup();hangup.setSchedule(60);hangup.setReason("rejected");Speakspeak=newSpeak("This call will be hung up after a minute");speak.setLoop(0);try{response.append(hangup);response.append(speak);System.out.println(response.toXML());resp.addHeader("Content-Type","text/xml");resp.getWriter().print(response.toXML());;}catch(PlivoExceptione){e.printStackTrace();}}publicstaticvoidmain(String[]args)throwsException{Stringport=System.getenv("PORT");if(port==null)port="8000";Serverserver=newServer(Integer.valueOf(port));ServletContextHandlercontext=newServletContextHandler(ServletContextHandler.SESSIONS);context.setContextPath("/");server.setHandler(context);context.addServlet(newServletHolder(newhangup()),"/hangup");server.start();server.join();}}/*
Sample Output
<Response>
<Hangup schedule="60" reason="rejected"/>
<Speak loop="0">
This call will be hung up after a minute
</Speak>
</Response>
*/
usingSystem;usingSystem.Collections.Generic;usingPlivo.XML;namespacePlivo{classMainClass{publicstaticvoidMain(string[]args){Plivo.XML.Responseresp=newPlivo.XML.Response();resp.AddHangup(newDictionary<string,string>(){{"schedule","60"},{"reason","rejected"}});resp.AddSpeak("Call will hangup after a min.",newDictionary<string,string>(){{"loop","0"}});varoutput=resp.ToString();Console.WriteLine(output);}}}//<Response>// <Hangup schedule = "60" reason="rejected" />// <Speak loop = "0" > Call will hangup after a min.</Speak>//</Response>
// Example for xml - hanguppackagemainimport"github.com/plivo/plivo-go/xml"funcmain(){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())}
Rate this page
🥳 Thank you! It means a lot to us!
×
Help Us Improve
Thank you so much for rating the page, we would like to get your input for further improvements!