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.js 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 messaging 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 plivo@4.8.0
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
Legacy | Latest |
var plivo = require('plivo');
| var plivo = require('plivo');
|
Initialize
Legacy | Latest |
var p = plivo.RestAPI({
authId: '<auth_id>',
authToken: '<auth_token>'
});
| var client = new plivo.Client('<auth_id>', '<auth_token>');
|
Access resources
Legacy | Latest |
p.send_message(params, function(status, response) {
console.log('Status: ', status);
console.log('API Response:\n', response);
});
});
| client.messages.create(params).then(function(response) {
console.log(response);
}, function(err) {
console.error(err);
});
|
Send a message
Legacy | Latest |
var plivo = require('plivo');
var p = plivo.RestAPI({
authId: '<auth_id>',
authToken: '<auth_token>'
});
var params = {
'src': '+12025551212',
'dst': '+12025552323 ',
'text': 'Hello, this is a sample text',
'url': 'https://<yourdomain>.com/report/',
'method': 'GET'
};
p.send_message(params, function(status, response) {
console.log('API Response:\n', response);
});
| var plivo = require('plivo');
(function main() {
'use strict';
var client = new plivo.Client('<auth_id>', '<auth_token>');
client.messages.create({
src: "+12025551212",
dst: "+12025552323",
text: "Hello, this is a sample text",
url: "https://<yourdomain>.com/sms_status/"
}).then(function(response) {
console.log(response);
});
})();
|
Retrieve a message
Legacy | Latest |
var plivo = require('plivo');
var p = plivo.RestAPI({
authId: '<auth_id>',
authToken: '<auth_token>'
});
var params = {
'record_id': '<your_message_uuid>'
};
p.get_message(params, function(status, response) {
console.log('Status: ', status);
console.log('API Response:\n', response);
console.log('Units:', response['units']);
console.log('Status:', response['message_state']);
});
| var plivo = require('plivo');
(function main() {
'use strict';
var client = new plivo.Client('<auth_id>', '<auth_token>');
client.messages.get('<your_message_uuid>', ).then(function(response) {
console.log(response);
}, );
})();
|
List all messages
Legacy | Latest |
var plivo = require('plivo');
var p = plivo.RestAPI({
authId: '<auth_id>',
authToken: '<auth_token>'
});
var params = {};
p.get_messages(params, function(status, response) {
console.log('Status: ', status);
console.log('API Response:\n', response);
});
var params1 = {
'limit': '5',
'offset': '0'
};
p.get_messages(params1, function(status, response) {
console.log('Status: ', status);
});
| var plivo = require('plivo');
(function main() {
'use strict';
var client = new plivo.Client('<auth_id>', '<auth_token>');
client.messages.list({
limit: 5,
offset: 0,
}).then(function(response) {
console.log(response);
}, );
})();
|
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.js 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 messaging 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 plivo@4.8.0
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
Legacy | Latest |
var plivo = require('plivo');
| var plivo = require('plivo');
|
Initialize
Legacy | Latest |
var p = plivo.RestAPI({
authId: '<auth_id>',
authToken: '<auth_token>'
});
| var client = new plivo.Client('<auth_id>', '<auth_token>');
|
Access resources
Legacy | Latest |
p.send_message(params, function(status, response) {
console.log('Status: ', status);
console.log('API Response:\n', response);
});
});
| client.messages.create(params).then(function(response) {
console.log(response);
}, function(err) {
console.error(err);
});
|
Send a message
Legacy | Latest |
var plivo = require('plivo');
var p = plivo.RestAPI({
authId: '<auth_id>',
authToken: '<auth_token>'
});
var params = {
'src': '+12025551212',
'dst': '+12025552323 ',
'text': 'Hello, this is a sample text',
'url': 'https://<yourdomain>.com/report/',
'method': 'GET'
};
p.send_message(params, function(status, response) {
console.log('API Response:\n', response);
});
| var plivo = require('plivo');
(function main() {
'use strict';
var client = new plivo.Client('<auth_id>', '<auth_token>');
client.messages.create({
src: "+12025551212",
dst: "+12025552323",
text: "Hello, this is a sample text",
url: "https://<yourdomain>.com/sms_status/"
}).then(function(response) {
console.log(response);
});
})();
|
Retrieve a message
Legacy | Latest |
var plivo = require('plivo');
var p = plivo.RestAPI({
authId: '<auth_id>',
authToken: '<auth_token>'
});
var params = {
'record_id': '<your_message_uuid>'
};
p.get_message(params, function(status, response) {
console.log('Status: ', status);
console.log('API Response:\n', response);
console.log('Units:', response['units']);
console.log('Status:', response['message_state']);
});
| var plivo = require('plivo');
(function main() {
'use strict';
var client = new plivo.Client('<auth_id>', '<auth_token>');
client.messages.get('<your_message_uuid>', ).then(function(response) {
console.log(response);
}, );
})();
|
List all messages
Legacy | Latest |
var plivo = require('plivo');
var p = plivo.RestAPI({
authId: '<auth_id>',
authToken: '<auth_token>'
});
var params = {};
p.get_messages(params, function(status, response) {
console.log('Status: ', status);
console.log('API Response:\n', response);
});
var params1 = {
'limit': '5',
'offset': '0'
};
p.get_messages(params1, function(status, response) {
console.log('Status: ', status);
});
| var plivo = require('plivo');
(function main() {
'use strict';
var client = new plivo.Client('<auth_id>', '<auth_token>');
client.messages.list({
limit: 5,
offset: 0,
}).then(function(response) {
console.log(response);
}, );
})();
|
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 messaging 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 higher.
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.
Import the SDK
Initialize
Legacy | Latest |
p = RestAPI.new("<auth_id>","<auth_token>")
| api = RestClient.new("<auth_id>","<auth_token>")
|
Access resources
Legacy | Latest |
response = p.send_message(params)
| response = api.messages.create(params)
|
Send a message
Legacy | Latest |
require 'rubygems'
require 'plivo'
include Plivo
AUTH_ID = "<auth_id>"
AUTH_TOKEN = "<auth_token>"
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)
params = {
'src' => '+12025551212',
'dst' => '+12025552323',
'text' => 'Hello, this is a sample text',
'url' => 'https://<yourdomain>.com/sms status/',
}
response = p.send_message(params)
puts response
| require 'plivo'
include Plivo
api = RestClient.new('<auth_id>','<auth_token>')
response = api.messages.create(
src:"+12025551212",
dst:"+12025552323",
text:"Hello, this is a sample text",
url:"https://<yourdomain>.com/sms status/",
)
puts response
|
Retrieve a message
Legacy | Latest |
require 'rubygems'
require 'plivo'
include Plivo
AUTH_ID = '<auth_id>'
AUTH_TOKEN = '<auth_token>'
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)
params = {'record_id' => '<your_message_uuid>'}
response = p.get_message(params)
| require 'rubygems'
require 'plivo'
include Plivo
api = RestClient.new('<auth_id>','<auth_token>')
response = api.messages.get('<your_message_uuid>')
puts response
|
List all messages
Legacy | Latest |
require 'rubygems'
require 'plivo'
include Plivo
AUTH_ID = "<auth_id>"
AUTH_TOKEN = "<auth_token>"
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)
response = p.get_messages()
puts response
params = {
'limit' => '5',
'offset' => '0',
}
response = p.get_messages(params)
puts response
| require 'plivo'
include Plivo
api = RestClient.new('<auth_id>','<auth_token>')
response = api.messages.list(
limit: 5,
offset: 0,
)
puts response
|
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 messaging 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.
Import the SDK
Legacy | Latest |
| import plivo
from plivo import plivoxml
|
Initialize
Legacy | Latest |
p = plivo.RestAPI('<auth_id>','<auth_token>')
| client = plivo.RestClient('<auth_id>','<auth_token>')
|
Access resources
Legacy | Latest |
response = p.send_message(params)
| response = client.messages.create(params)
|
Send a message
Legacy | Latest |
import plivo
auth_id = "<auth_id>"
auth_token = "<auth_token>"
p = plivo.RestAPI(auth_id, auth_token)
params = {
"src": "+12025551212",
"dst": "+12025552323",
"text": "Hello, this is a sample text",
"url": "https://<yourdomain>.com/sms_status/",
}
response = p.send_message(params)
print str(response)
| import plivo
client = plivo.RestClient("<auth_id>", "<auth_token>")
response = client.messages.create(
src="+12025551212",
dst="+12025552323",
text="Hello, this is a sample text",
url="https://<yourdomain>.com/sms_status/",
)
print(response)
|
Retrieve a message
Legacy | Latest |
import plivo
auth_id = "<auth_id>"
auth_token = "<auth_token>"
p = plivo.RestAPI(auth_id, auth_token)
params = {"message_uuid": "<your_message_uuid>"}
response = p.get_message(params)
print str(response)
| import plivo
client = plivo.RestClient("<auth_id>", "<auth_token>")
response = client.messages.get(message_uuid="<your_message_uuid>")
print(response)
|
List all messages
Legacy | Latest |
import plivo
auth_id = "<auth_id>"
auth_token = "<auth_token>"
p = plivo.RestAPI(auth_id, auth_token)
response = p.get_messages()
print str(response)
params = {
"limit": "5",
"offset": "0",
}
response = p.get_messages(params)
print str(response)
| import plivo
client = plivo.RestClient("<auth_id>", "<auth_token>")
response = client.messages.list(
limit=5,
offset=0,
)
print(response)
|
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 messaging 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
Legacy | Latest |
<?php
require 'vendor/autoload.php';
use Plivo\RestAPI;
| <?php
require 'vendor/autoload.php';
use Plivo\RestClient;
|
Initialize
Legacy | Latest |
$p = new RestAPI($auth_id, $auth_token);
| $client = new RestClient("<auth_id>","<auth_token>");
|
Access resources
Legacy | Latest |
$response = $p->send_message($params);
| $response = $client->messages->create($params);
|
Send a message
Legacy | Latest |
<?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(
'src' => '+12025551212',
'dst' => '+12025552323',
'text' => 'Hello, this is a sample text',
'url' => 'https://<yourdomain>.com/sms_status/'
);
$response = $p->send_message($params);
echo "Response : ";
print_r ($response['response']);
?>
| <?php
require 'vendor/autoload.php';
use Plivo\RestClient;
$client = new RestClient('<auth_id>','<auth_token>');
$response = $client->messages->create(
[
"src" => "+12025551212",
"dst" => "+12025552323",
"text" =>"Hello, this is a sample text",
"url"=>"https://<yourdomain>.com/sms_status/"
]
);
print_r($response);
?>
|
Retrieve a message
Legacy | Latest |
<?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('record_id' => '<your_message_uuid>');
$response = $p->get_message($params);
print_r ($response['response']);
?>
| <?php
require 'vendor/autoload.php';
use Plivo\RestClient;
$client = new RestClient('<auth_id>','<auth_token>');
$response = $client->messages->get('<your_message_uuid>');
print_r($response);
?>
|
List all messages
Legacy | Latest |
<?php
require 'vendor/autoload.php';
use Plivo\RestAPI;
$auth_id = '<auth_id>';
$auth_token = '<auth_token>';
$p = new RestAPI($auth_id, $auth_token);
$response = $p->get_messages();
print_r ($response['response']);
$params = array(
'limit' => '5',
'offset' => '0',
);
$response = $p->get_messages($params);
print_r ($response['response']);
?>
| <?php
require 'vendor/autoload.php';
use Plivo\RestClient;
$client = new RestClient('<auth_id>','<auth_token>');
$response = $client->messages->list(
[
'limit' => 5,
'offset' => 0
]
);
print_r($response);
?>
|
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: We’re deprecating Plivo .NET SDK legacy versions lower than v4.10.0 on January 31, 2022. If you use a deprecated version of our SDK after that date, your API requests and messaging 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, you should check every program that depends on the SDK and make changes to the syntax for several kinds of operations. Here are examples of how coding differs between the deprecated legacy versions of the SDK and the latest active versions.
Import the SDK
Legacy | Latest |
using System;
using System.Collections.Generic;
using RestSharp;
using Plivo.API;
| using System;
using System.Collections.Generic;
using Plivo;
|
Initialize
Legacy | Latest |
RestAPI plivo = new RestAPI("<auth_id>","<auth_token>");
| var api = new PlivoApi("<auth_id>","<auth_token>");
|
Access resources
Legacy | Latest |
IRestResponse < MessageResponse > resp =
plivo.send_message(new Dictionary < string, string > () {params});
| var response = api.Message.Create(params);
|
Send a message
Legacy | Latest |
using System;
using System.Collections.Generic;
using System.Reflection;
using RestSharp;
using Plivo.API;
namespace Send_Sms
{
class Program
{
static void Main(string[] args)
{
RestAPI plivo = new RestAPI("<auth_id>", "<auth_token>");
IRestResponse<MessageResponse> resp = plivo.send_message(new Dictionary<string, string>()
{
{ "src", "+12025551212" },
{ "dst", "+12025552323" },
{ "text", "Hello, this is a sample text" },
{ "url", "https://<yourdomain>.com/sms_status/"}
});
Console.Write(resp.Content);
Console.ReadLine();
}
}
}
| using System;
using System.Collections.Generic;
using Plivo;
namespace PlivoExamples
{
internal class Program
{
public static void Main(string[] args)
{
var api = new PlivoApi("<auth_id>","<auth_token>");
var response = api.Message.Create(
src: "+12025551212",
dst: "+12025552323",
text: "Hello, this is a sample text",
url: "https://<yourdomain>.com/sms_status/"
);
Console.WriteLine(response);
}
}
}
|
Retrieve a message
Legacy | Latest |
using System;
using System.Collections.Generic;
using System.Reflection;
using RestSharp;
using Plivo.API;
namespace Get_Details
{
class Program
{
static void Main(string[] args)
{
RestAPI plivo = new RestAPI("<auth_id>", "<auth_token>");
IRestResponse<Message> resp = plivo.get_message(new Dictionary<string, string>()
{
{ "record_id", "<your_message_uuid>" }
});
Console.Write(resp.Content);
Console.ReadLine();
}
}
}
| using System;
using Plivo;
using Plivo.Exception;
namespace PlivoExamples
{
internal class Program
{
public static void Main(string[] args)
{
var api = new PlivoApi("<auth_id>","<auth_token>");
var response = api.Message.Get(
messageUuid: "<your_message_uuid>"
);
Console.WriteLine(response);
}
}
}
|
List all messages
Legacy | Latest |
using System;
using System.Collections.Generic;
using System.Reflection;
using RestSharp;
using Plivo.API;
namespace GetAllDetails
{
class Program
{
static void Main(string[] args)
{
RestAPI plivo = new RestAPI("<auth_id>","<auth_token>");
IRestResponse<MessageList> resp = plivo.get_messages();
Console.Write(resp.Content);
IRestResponse<MessageList> response = plivo.get_messages(new Dictionary<string, string>()
{
{ "limit", "10" },
{ "offset", "0" }
});
Console.WriteLine(response.Content);
Console.ReadLine();
}
}
}
| using System;
using System.Collections.Generic;
using Plivo;
namespace PlivoExamples
{
internal class Program
{
public static void Main(string[] args)
{
var api = new PlivoApi("<auth_id>","<auth_token>");
var response = api.Message.List(
limit:10,
offset:0
);
Console.WriteLine(response);
}
}
}
|
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 messaging 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 command Update-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
Legacy | Latest |
import com.plivo.helper.api.client.*;
import com.plivo.helper.xml.elements.Dial;
| import com.plivo.api.Plivo;
import com.plivo.api.xml.Dial;
|
Initialize
Legacy | Latest |
RestAPI api = new RestAPI("<auth_id>","<auth_token>", "v1");
| Plivo.init("<auth_id>","<auth_token>");
|
Access resources
Legacy | Latest |
Message resp = api.makeCall(parameters);
| MessageCreateResponse response = Message.creator(parameters)
.create();
|
Send a message
Legacy | Latest |
package com.plivo.test;
import java.util.LinkedHashMap;
import com.plivo.helper.api.client.*;
import com.plivo.helper.api.response.message.MessageResponse;
import com.plivo.helper.exception.PlivoException;
public class SendMessage {
public static void main(String[] args) {
String authId = "<auth_id>";
String authToken = "<auth_token>";
RestAPI api = new RestAPI(authId, authToken, "v1");
LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
parameters.put("src", "12025551212");
parameters.put("dst", "12025552323");
parameters.put("text", "Hello, this is a test message");
parameters.put("url", "https://<yourdomain>.com/sms_status/");
try {
MessageResponse msgResponse = api.sendMessage(parameters);
System.out.println(msgResponse);
} catch (PlivoException e) {
System.out.println(e.getLocalizedMessage());
}
}
}
| import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.message.Message;
import com.plivo.api.models.message.MessageCreateResponse;
class MessageCreate
{
public static void main(String [] args)
{
Plivo.init("<auth_id>","<auth_token>");
try
{
MessageCreateResponse response = Message.creator("+12025551212","+12025552323",
"Hello, this is a test message")
.url(new URL("https://<yourdomain>.com/sms_status/") )
.create();
System.out.println(response);
}
catch (PlivoRestException | IOException e)
{
e.printStackTrace();
}
}
}
|
Retrieve a message
Legacy | Latest |
package com.plivo.test;
import java.util.LinkedHashMap;
import com.plivo.helper.api.client.*;
import com.plivo.helper.api.response.message.MessageResponse;
import com.plivo.helper.exception.PlivoException;
public class GetDetails {
public static void main(String[] args) {
String authId = "<auth_id>";
String authToken = "<auth_token>";
RestAPI api = new RestAPI(authId, authToken, "v1");
LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
parameters.put("record_id", "<your_message_uuid>");
try {
Message msg = api.getMessage(parameters);
System.out.println(msg);
} catch (PlivoException e) {
System.out.println(e.getLocalizedMessage());
}
}
}
| import java.io.IOException;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.message.Message;
class MessageGet
{
public static void main(String [] args)
{
Plivo.init("<auth_id>", "<auth_token>");
try
{
Message response = Message.getter("<your_message_uuid>")
.get();
System.out.println(response);
}
catch (PlivoRestException | IOException e)
{
e.printStackTrace();
}
}
}
|
List all messages
Legacy | Latest |
package com.plivo.test;
import java.util.LinkedHashMap;
import com.plivo.helper.api.client.*;
import com.plivo.helper.api.response.message.MessageResponse;
import com.plivo.helper.exception.PlivoException;
public class GetAllDetails {
public static void main(String[] args) {
String authId = "<auth_id>";
String authToken = "<auth_token>";
RestAPI api = new RestAPI(authId, authToken, "v1");
try {
MessageFactory msg = api.getMessages();
System.out.println(msg);
} catch (PlivoException e) {
System.out.println(e.getLocalizedMessage());
}
LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
parameters.put("limit", "5");
parameters.put("offset", "0");
try {
MessageFactory msg = api.getMessages(parameters);
System.out.println(msg);
} catch (PlivoException e) {
System.out.println(e.getLocalizedMessage());
}
}
}
| import java.io.IOException;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.message.Message;
import com.plivo.api.models.base.ListResponse;
class GetAllMessageList
{
public static void main(String [] args)
{
Plivo.init("<auth_id>","<auth_token>");
try
{
ListResponse<Message> response = Message.lister()
.limit(5)
.offset(0)
.list();
System.out.println(response);
}
catch (PlivoRestException | IOException e)
{
e.printStackTrace();
}
}
}
|