- Node
- Ruby
- Python
- PHP
- .NET
- Java
Upgrade from Node.js Legacy to v4.8.0 or Latest Version
Introduction
This is a major application update. Plivo recommends you always use the latest or an active version of our SDKs for guaranteed security, stability, and uptime. The active SDK versions are designed to handle intermittent and regional failures of API requests. In addition, they offer a host of security features, such as protection against DoS attacks and bot detection for suspicious user agents.Deprecation notice: We’re deprecating Plivo Node SDK legacy versions lower than v4.8.0 on January 31, 2022. If you use a deprecated version of our SDK after that date, your API requests and voice calls may fail intermittently. Plivo will no longer provide bug fixes to these versions, and our support team may ask you to upgrade before debugging issues.
Migrate your applications
Node.js version support
The 4.x version of the Plivo SDK is compatible with Node.js versions 5.5 and higher.Use the command npm install [email protected] to upgrade to the active version of the SDK, or npm install plivo@latest to upgrade to the latest version.After you upgrade to the latest version of the SDK, you should check every program that depends on it and make changes to the syntax for several kinds of operations. Here are examples of how coding differs between the deprecated legacy version of the SDK and the latest active versions.Import the SDK
Copy
Ask AI
var plivo = require('plivo');
Initialize
Copy
Ask AI
var p = plivo.RestAPI({
authId: '<auth_id>',
authToken: '<auth_token>'
});
Access resources
Copy
Ask AI
p.make_call(params, function (status, response) {
console.log('Status: ', status);
console.log('API Response:\n', response);
});
Make a call
Copy
Ask AI
var plivo = require('plivo');
var p = plivo.RestAPI({
authId: '<auth_id>',
authToken: '<auth_token>'
});
var params = {
'to': '2025552323',
'from' : '2025551212',
'answer_url' : "https://s3.amazonaws.com/static.plivo.com/answer.xml",
'answer_method' : "GET"
};
p.make_call(params, function (status, response) {
console.log('Status: ', status);
console.log('API Response:\n', response);
});
Dial XML
Copy
Ask AI
var plivo = require('plivo');
var response = plivo.Response();
var params = {
'dialMusic': "https://<yourdomain>.com/dial_music/"
};
var dial = response.addDial(params);
var first_number = "12025551212";
dial.addNumber(first_number);
console.log(response.toXML());
Conference XML
Copy
Ask AI
var plivo = require('plivo');
var response = plivo.Response();
var params = {
'startConferenceOnEnter': "false",
'waitSound': "https://<yourdomain>.com/waitMusic/"
};
var conference_name = "My Room";
response.addConference(conference_name, params);
console.log(response.toXML());
Record API
Copy
Ask AI
var plivo = require('plivo');
var p = plivo.RestAPI({
"authId": "<auth_id>",
"authToken": "<auth_token>"
});
var params = {'call_uuid':call_uuid};
var response = p.record(params);
console.log(response);
Record XML
Copy
Ask AI
var plivo = require('plivo');
var response = plivo.Response();
var params = {
'action': "https://<yourdomain>.com/get_recording/",
'startOnDialAnswer': "true",
'redirect': "false"
};
response.addRecord(params);
var dial = response.addDial();
var number = "12025552323";
dial.addNumber(number);
console.log(response.toXML());
Upgrade from Ruby Legacy to v4.9.0 or Latest Version
Introduction
This is a major application update. Plivo recommends you always use the latest or an active version of our SDKs for guaranteed security, stability, and uptime. The active SDK versions are designed to handle intermittent and regional failures of API requests. In addition, they offer a host of security features, such as protection against DoS attacks and bot detection for suspicious user agents.Deprecation notice: We’re deprecating Plivo Ruby SDK legacy versions lower than v4.9.0 on January 31, 2022. If you use a deprecated version of our SDK after that date, your API requests and voice calls may fail intermittently. Plivo will no longer provide bug fixes to these versions, and our support team may ask you to upgrade before debugging issues.
Migrate your applications
Ruby version support
The Plivo Ruby SDK supports Ruby 2.0 and above.Use the command gem install plivo -v 4.9.0 to upgrade to the active version of the SDK, or gem update plivo to upgrade to the latest version.After you upgrade to the latest version of the SDK, you should check every program that depends on it and make changes to the syntax for several kinds of operations. Here are examples of how coding differs between the deprecated legacy version of the SDK and the latest active versions.Importing the SDK
Copy
Ask AI
require 'plivo'
Initialize
Copy
Ask AI
p = RestAPI.new("<auth_id>","<auth_token>")
Access Resources
Copy
Ask AI
response = p.make_call(params)
Make a call
Copy
Ask AI
require 'rubygems'
require 'plivo'
include Plivo
AUTH_ID = "<auth_id>"
AUTH_TOKEN = "<auth_token>"
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)
params = {
'to' => '12025552323',
'from' => '12025551212',
'answer_url' => 'https://s3.amazonaws.com/static.plivo.com/answer.xml',
'answer_method' => 'GET'
}
response = p.make_call(params)
print response
Dial XML
Copy
Ask AI
require 'rubygems'
require 'plivo'
include Plivo
response = Response.new()
params = {
'dialMusic' => "https://<yourdomain>.com/dial_music/"
}
dial = response.addDial(params)
first_number = "12025552323"
dial.addNumber(first_number)
puts response.to_xml()
Conference XML
Copy
Ask AI
require 'rubygems'
require 'plivo'
include Plivo
response = Response.new()
params = {
'startConferenceOnEnter' => "false",
'waitSound' => "https://<yourdomain>.com/waitmusic/"
}
conference_name = "My Room"
response.addConference(conference_name, params)
puts response.to_xml()
Record API
Copy
Ask AI
require 'rubygems'
require 'plivo'
AUTH_ID = "<auth_id>"
AUTH_TOKEN = "<auth_token>"
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)
params = {'call_uuid' => call_uuid}
response = p.record(params)
print response
Record XML
Copy
Ask AI
require 'rubygems'
require 'plivo'
include Plivo
response = Response.new()
params = {
'action' => "https://<yourdomain>.com/get_recording/",
'startOnDialAnswer' => "true",
'redirect' => "false"
}
response.addRecord(params)
dial = response.addDial()
number = "12025552323"
dial.addNumber(number)
puts response.to_xml()
Upgrade from Python SDK Legacy to v4.9.0 or Latest Version
Introduction
This is a major application update. Plivo recommends you always use the latest or an active version of our SDKs for guaranteed security, stability, and uptime. The active SDK versions are designed to handle intermittent and regional failures of API requests. In addition, they offer a host of security features, such as protection against DoS attacks and bot detection for suspicious user agents.Deprecation notice: We’re deprecating Plivo Python SDK legacy versions lower than v4.9.0 on January 31, 2022. If you use a deprecated version of our SDK after that date, your API requests and voice calls may fail intermittently. Plivo will no longer provide bug fixes to these versions, and our support team may ask you to upgrade before debugging issues.
Migrate your applications
Python version support
Version 4.x of the Python SDK requires at least Python version 2.7. It will work with later versions, including Python 3.x versions.Use the command pip install —upgrade plivo==4.9.0 to upgrade to the active version of the SDK, or pip install —upgrade plivo to upgrade to the latest version.After you upgrade to the latest version of the SDK, you should check every program that depends on it and make changes to the syntax for several kinds of operations. Here are examples of how coding differs between the deprecated legacy version of the SDK and the latest active versions.Importing the SDK
Copy
Ask AI
import plivo, plivoxml
Initializing
Copy
Ask AI
p = plivo.RestAPI('<auth_id>','<auth_token>')
Accessing resources
Copy
Ask AI
response = p.make_call(params)
Making a call
Copy
Ask AI
import plivo, plivoxml
p = plivo.RestAPI('<auth_id>','<auth_token>')
params = {
'to': '<destination_number>',
'from' : '<caller_id>',
'answer_url' : 'https://s3.amazonaws.com/static.plivo.com/answer.xml',
'answer_method' : "GET",
}
response = p.make_call(params)
print str(response)
Dial XML
Copy
Ask AI
from flask import Flask, Response, request
import plivoxml
app=Flask(__name__)
@app.route('/dial/caller_tone/', methods=['GET','POST'])
def caller_tone():
response = plivoxml.Response()
params = {
'dialMusic' : "https://<yourdomain>.com/dial_music/"
}
Dial = response.addDial(**params)
number = "<destination_number>"
Dial.addNumber(number)
return Response(str(response), mimetype='text/xml')
if __name__ == "__main__":
app.run(host='0.0.0.0', debug=True)
Conference XML
Copy
Ask AI
from flask import Flask, Response, request
import plivoxml
app=Flask(__name__)
@app.route('/conference/moderated/', methods=['GET','POST'])
def moderated_conference():
response = plivoxml.Response()
params = {
'startConferenceOnEnter' : "false",
'endConferenceOnExit' : "true",
'waitSound' : "https://<yourdomain>.com/waitmusic/"
}
conference_name = "My Room"
response.addConference(conference_name, **params)
return Response(str(response), mimetype='text/xml')
if __name__ == "__main__":
app.run(host='0.0.0.0', debug=True)
Record API
Copy
Ask AI
import plivo
p = plivo.RestAPI(auth_id, auth_token)
params = {'call_uuid' : call_uuid}
response = p.record(params)
print str(response)
Record XML
Copy
Ask AI
from flask import Flask, Response, request
import plivoxml
app=Flask(__name__)
@app.route('/record/session/', methods=['GET','POST'])
def session():
response = plivoxml.Response()
params = {
'startOnDialAnswer' : "true",
'action' : "https://<yourdomain>.com/get_recording/",
'redirect' : "false"
}
response.addRecord(**params)
dial = response.addDial()
dial.addNumber("<destination_number>")
return Response(str(response), mimetype='text/xml')
if __name__ == "__main__":
app.run(host='0.0.0.0', debug=True)
Upgrade from PHP SDK Legacy to v4.25.0 or Latest Version
Introduction
This is a major application update. Plivo recommends you always use the latest or an active version of our SDKs for guaranteed security, stability, and uptime. The active SDK versions are designed to handle intermittent and regional failures of API requests. In addition, they offer a host of security features, such as protection against DoS attacks and bot detection for suspicious user agents.Deprecation notice: We’re deprecating Plivo PHP SDK legacy versions lower than 4.25.0 on January 31, 2022. If you use a deprecated version of our SDK after that date, your API requests and voice calls may fail intermittently. Plivo will no longer provide bug fixes to these versions, and our support team may ask you to upgrade before debugging issues.
Migrate your applications
PHP version support
The 4.x version of the Plivo SDK is compatible with PHP versions 7.3 and higher.Use the command composer require plivo/plivo-php:4.25.0 to upgrade to the active version of the SDK, or composer require plivo/plivo-php to upgrade to the latest version.After you upgrade to the latest version of the SDK, you should check every program that depends on it and make changes to the syntax for several kinds of operations. Here are examples of how coding differs between the deprecated legacy version of the SDK and the latest active versions.Import the SDK
Copy
Ask AI
<?php
require 'vendor/autoload.php';
use Plivo\RestAPI;
Initialize
Copy
Ask AI
$p = new RestAPI($auth_id, $auth_token);
Access resources
Copy
Ask AI
$response = $p->make_call($params);
Make a call
Copy
Ask AI
<?php
require 'vendor/autoload.php';
use Plivo\RestAPI;
$auth_id = "<auth_id>";
$auth_token = "<auth_token>";
$p = new RestAPI($auth_id, $auth_token);
$params = array(
'to' => '2025552323',
'from' => '2025551212',
'answer_url' => "https://s3.amazonaws.com/static.plivo.com/answer.xml",
'answer_method' => "GET"
);
$response = $p->make_call($params);
print_r ($response);
Dial XML
Copy
Ask AI
<?php
require '../vendor/autoload.php';
use Plivo\Response;
$response = new Response();
$params = array(
'dialMusic' => "https://<yourdomain>.com/dial_music/"
);
$dial = $response->addDial($params);
$number = "12025552323";
$dial->addNumber($number);
Header('Content-type: text/xml');
echo($response->toXML());
Conference XML
Copy
Ask AI
<?php
require '../vendor/autoload.php';
use Plivo\Response;
$response = new Response();
$params = array(
'startConferenceOnEnter' => "false",
'waitSound' => "https://<yourdomain>.com/waitmusic/"
);
$conference_name = "My Room";
$response->addConference($conference_name, $params);
Header('Content-type: text/xml');
echo($response->toXML());
Record API
Copy
Ask AI
<?php
require 'vendor/autoload.php';
use Plivo\RestAPI;
$auth_id = "<auth_id>";
$auth_token = "<auth_token>";
$p = new RestAPI($auth_id, $auth_token);
$params = array('call_uuid' => $uuid);
$response = $p->record($params);
print("URL : {$response['response']['url']}");
Record XML
Copy
Ask AI
<?php
require '../vendor/autoload.php';
use Plivo\Response;
$response = new Response();
$params = array(
'action' => "https://<yourdomain>.com/get_recording/",
'startOnDialAnswer' => "true",
'redirect' => "false"
);
$response->addRecord($params);
$dial = $response->addDial();
$number = "2025552323";
$dial->addNumber($number);
Header('Content-type: text/xml');
echo($response->toXML());
Upgrade from .NET SDK Legacy to v4.10.0 or Latest Version
Introduction
This is a major application update. Plivo recommends you always use the latest or an active version of our SDKs for guaranteed security, stability, and uptime. The active SDK versions are designed to handle intermittent and regional failures of API requests. In addition, they offer a host of security features, such as protection against DoS attacks and bot detection for suspicious user agents.Deprecation notice: Plivo .NET SDK legacy versions lower than v4.10.0 are being deprecated on January 31, 2022. If you use a deprecated version of our SDK after that date, your API requests and voice calls may fail intermittently. Plivo will no longer provide bug fixes to these versions, and our support team may ask you to upgrade before debugging issues.
Migrate your applications
.NET version support
The Plivo .NET SDK supports .NET applications written in C# and Visual Basic that utilize the .NET Framework version 3.5 or higher or any .NET runtime supporting .NET Standard v1.4.Use the command Update-Package Plivo -Version 4.10.0 to upgrade to the active version of the SDK, or Update-Package Plivo to upgrade to the latest version.After you upgrade to the latest version of the SDK, you should check every program that depends on it and make changes to the syntax for several kinds of operations. Here are examples of how coding differs between the deprecated legacy version of the SDK and the latest active versions.Import the SDK
Copy
Ask AI
using System;
using System.Collections.Generic;
using RestSharp;
using Plivo.API;
Initialize
Copy
Ask AI
RestAPI plivo = new RestAPI("<auth_id>","<auth_token>");
Access resources
Copy
Ask AI
IRestResponse<Call> resp = plivo.make_call(new Dictionary<string, string>()
{params});
Make a call
Copy
Ask AI
using System;
using System.Collections.Generic;
using RestSharp;
using Plivo.API;
namespace make_calls
{
class Program
{
static void Main(string[] args)
{
RestAPI plivo = new RestAPI("<auth_id>", "<auth_token>");
IRestResponse<Call> resp = plivo.make_call(new Dictionary<string, string>()
{
{ "from", "2025551212" },
{ "to", "2025552323" },
{ "answer_url", "https://s3.amazonaws.com/static.plivo.com/answer.xml" },
{ "answer_method","GET"},
});
Console.Write(resp.Content);
Console.ReadLine();
}
}
}
Dial XML
Copy
Ask AI
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();
Plivo.XML.Dial dial = new Plivo.XML.Dial(new
Dictionary<string, string>() {
{"dialMusic", "https://<yourdomain>.com/dial_music/"}
});
dial.AddNumber("12025552323",
new Dictionary<string, string>() { });
resp.Add(dial);
var output = resp.ToString();
Console.WriteLine(output);
}
}
}
Conference XML
Copy
Ask AI
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.AddConference("My room",
new Dictionary<string, string>()
{
{"startConferenceOnEnter", "true"},
{"endConferenceOnExit", "true"},
{"waitSound", "https://<yourdomain>.com/waitmusic/"}
});
var output = resp.ToString();
Console.WriteLine(output);
}
}
}
Record API
Copy
Ask AI
using System;
using System.Collections.Generic;
using System.Diagnostics;
using RestSharp;
using Plivo.API;
namespace PlivoExamples
{
internal class Program
{
public static void Main(string[] args)
{
string auth_id = "<auth_id>";
string auth_token = "<auth_token>";
RestAPI plivo = new RestAPI(auth_id, auth_token);
IRestResponse<Plivo.API.Record> resp = plivo.record(new Dictionary<string, string>()
{
{ "call_uuid", uuid } // ID of the call
});
Debug.WriteLine(resp.Content);
}
}
}
Record XML
Copy
Ask AI
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.AddRecord(new Dictionary<string, string>() {
{"action", "https://<yourdomain>.com/get_recording/"},
{"startOnDialAnswer", "true"},
{"redirect", "false"}
});
Plivo.XML.Dial dial = new Plivo.XML.Dial(new
Dictionary<string, string>()
{ });
dial.AddNumber("12025552323",
new Dictionary<string, string>() { });
resp.Add(dial);
var output = resp.ToString();
Console.WriteLine(output);
}
}
}
Upgrade from Java Legacy to v4.8.0 or Latest Version
Introduction
This is a major application update. Plivo recommends you always use the latest or an active version of our SDKs for guaranteed security, stability, and uptime. The active SDK versions are designed to handle intermittent and regional failures of API requests. In addition, they offer a host of security features, such as protection against DoS attacks and bot detection for suspicious user agents.Deprecation notice: We’re deprecating Plivo Java SDK legacy versions lower than v4.8.0 on January 31, 2022. If you use a deprecated version of our SDK after that date, your API requests and voice calls may fail intermittently. Plivo will no longer provide bug fixes to these versions, and our support team may ask you to upgrade before debugging issues.
Migrate your applications
Java version support
The Plivo Java SDK supports OpenJDK 8 and 11 and OracleJDK 8 and 11.Use the commandUpdate-Package Plivo -Version 4.10.0 to upgrade to the active version of the SDK, or upgrade to the latest version.After you upgrade to the latest version of the SDK, you should check every program that depends on it and make changes to the syntax for several kinds of operations. Here are examples of how coding differs between the deprecated legacy version of the SDK and the latest active versions.Import the SDK
Copy
Ask AI
import com.plivo.helper.api.client.*;
import com.plivo.helper.xml.elements.Dial;
Initialize
Copy
Ask AI
RestAPI api = new RestAPI("<auth_id>","<auth_token>", "v1");
Accessing resources
Copy
Ask AI
Call resp = api.makeCall(parameters);
Make a call
Copy
Ask AI
package com.plivo.test;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.LinkedHashMap;
import com.plivo.helper.api.client.*;
import com.plivo.helper.api.response.call.Call;
import com.plivo.helper.exception.PlivoException;
public class App {
public static void main(String[] args) throws IllegalAccessException {
String auth_id = "<auth_id>";
String auth_token = "<auth_token>";
RestAPI api = new RestAPI(auth_id, auth_token, "v1");
LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
parameters.put("to","2025552323");
parameters.put("from","2025551212");
parameters.put("answer_url","https://s3.amazonaws.com/static.plivo.com/answer.xml");
parameters.put("answer_method","GET");
try {
Call resp = api.makeCall(parameters);
System.out.println(resp);
} catch (PlivoException e) {
System.out.println(e.getLocalizedMessage());
}
}
}
Dial XML
Copy
Ask AI
import java.io.IOException;
import com.plivo.helper.exception.PlivoException;
import com.plivo.helper.xml.elements.Number;
import com.plivo.helper.xml.elements.Dial;
import com.plivo.helper.xml.elements.PlivoResponse;
class CustomCallerTone {
public static void main(String[] args) throws PlivoXmlException {
PlivoResponse response = new PlivoResponse();
Dial dial = new Dial();
dial.setDialMusic("https://<yourdomain>.com/dial_music/");
Number number = new Number("12025552323");
response.append(dial);
dial.append(number);
System.out.println(response.toXML());
resp.addHeader("Content-Type", "text/xml");
resp.getWriter().print(response.toXML());;
}
}
Conference XML
Copy
Ask AI
import java.io.IOException;
import com.plivo.helper.exception.PlivoException;
import com.plivo.helper.xml.elements.Conference;
import com.plivo.helper.xml.elements.PlivoResponse;
class ModeratedConference {
public static void main(String[] args) throws PlivoException {
PlivoResponse response = new PlivoResponse();
Conference conference = new Conference("My Room");
conference.setEnterSound("");
conference.setStartConferenceOnEnter(true);
conference.setEndConferenceOnExit(true);
conference.setWaitSound("https://<yourdomain>.com/music/");
response.append(conference);
System.out.println(response.toXML());
resp.addHeader("Content-Type", "text/xml");
resp.getWriter().print(response.toXML());;
}
}
Record API
Copy
Ask AI
package plivoexample;
import java.io.IOException;
import java.util.LinkedHashMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.plivo.helper.api.client.RestAPI;
import com.plivo.helper.api.response.response.Record;
import com.plivo.helper.exception.PlivoException;
class recordApiAction {
public static void main(String[] args) throws PlivoException {
String auth_id = "<auth_id>";
String auth_token = "<auth_token>";
RestAPI api = new RestAPI(auth_Id, auth_Token, "v1");
LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
parameters.put("call_uuid",call_uuid);
Record record = api.record(parameters);
System.out.println(record);
}
}
Record XML
Copy
Ask AI
import java.io.IOException;
import com.plivo.helper.exception.PlivoException;
import com.plivo.helper.xml.elements.Record;
import com.plivo.helper.xml.elements.Dial;
import com.plivo.helper.xml.elements.Number;
import com.plivo.helper.xml.elements.PlivoResponse;
class recordSession {
public static void main(String[] args) throws PlivoException {
response.append(record);
response.append(dial);
dial.append(number);
System.out.println(response.toXML());
resp.addHeader("Content-Type", "text/xml");
resp.getWriter().print(response.toXML());;
}
}