Learn how to quickly modify your existing Plivo API calls to send SMS messages using the SMS Gateway Emulator app. With minimal code changes, you can switch from Plivo services to our app, saving costs and gaining full control over your SMS gateway.
There are 2 ways to emulate Plivo API.
Change the API url directly.
Via our Proxy Server.
Whatever you do, make sure to change the PLIVO_AUTH_ID
, PLIVO_AUTH_TOKEN
to
EMULATOR_PLIVO_AUTH_ID
, EMULATOR_PLIVO_AUTH_TOKEN
, and set
EMULATOR_SENDER_ID
.
https://www.plivo.com/docs/messaging/api/overview/
https://www.plivo.com/docs/messaging/api/message#send-a-message
curl -i --user auth_id:auth_token \
-H "Content-Type: application/json" \
-d "{\"src\": \"<from_number>\",\"dst\": \"+12025551111\", \"text\": \"Hello, this is sample text\"}" \
https://api.plivo.com/v1/Account/{auth_id}/Message/
curl -i --user $EMULATOR_PLIVO_AUTH_ID:$EMULATOR_PLIVO_AUTH_TOKEN \
-H "Content-Type: application/json" \
-d "{\"src\": \"$EMULATOR_SENDER_ID\",\"dst\": \"+12025551111\", \"text\": \"Hello, this is sample text\"}" \
https://api.smsgatewayemulator.com/v1/Account/$EMULATOR_PLIVO_AUTH_ID/Message/
curl -i --user $EMULATOR_PLIVO_AUTH_ID:$EMULATOR_PLIVO_AUTH_TOKEN \
-H "Content-Type: application/json" \
-d "{\"src\": \"$EMULATOR_SENDER_ID\",\"dst\": \"+12025551111\", \"text\": \"Hello, this is sample text\"}" \
https://api.smsgatewayemulator.com/v1/Account/$EMULATOR_PLIVO_AUTH_ID/Message/ \
--cacert ./sms_gateway_emulator_ca.crt \
--proxy https://proxy.smsgatewayemulator.com \
--proxy-cacert ./sms_gateway_emulator_ca.crt
import os
import plivo
client = plivo.RestClient(os.environ["PLIVO_AUTH_ID"], os.environ["PLIVO_AUTH_TOKEN"])
response = client.messages.create(
src='from_number',
dst='+15558675310',
text='Hello, from Plivo')
print(response)
import os
import plivo
from requests.sessions import Session
# Save the original Session.__init__
original_init = Session.__init__
# Monkey patch Session.__init__
def patched_init(session_self, *args, **kwargs):
original_init(session_self, *args, **kwargs)
session_self.verify = os.path.abspath('./sms_gateway_emulator_ca.crt')
# Apply patch
Session.__init__ = patched_init
try:
client = plivo.RestClient(os.environ["EMULATOR_PLIVO_AUTH_ID"], os.environ["EMULATOR_PLIVO_AUTH_TOKEN"], proxies={'https': 'https://proxy.smsgatewayemulator.com'})
response = client.messages.create(
src=os.environ["EMULATOR_SENDER_ID"],
dst='+15558675310',
text='Hello, from Plivo Emulator'
)
print(response)
finally:
# Restore the original Session.__init__
Session.__init__ = original_init
var plivo = require('plivo');
(function main() {
'use strict';
var client = new plivo.Client("<auth_id>", "<auth_token>");
client.messages.create(
{
src: "<from_number>",
dst: "<destination_number>",
text: "Hello, this is sample text",
url: "https://<yourdomain>.com/sms_status/"
}
).then(function (response) {
console.log(response);
});
})();
var plivo = require('plivo');
(function main() {
'use strict';
var client = new plivo.Client(.env.EMULATOR_PLIVO_AUTH_ID, process.env.EMULATOR_PLIVO_AUTH_TOKEN, {url: "https://api.smsgatewayemulator.com/v1/Account/" + process.env.EMULATOR_PLIVO_AUTH_ID});
client.messages.create(
{
src: process.env.EMULATOR_SENDER_ID,
dst: "N:Node.js Demo",
text: "Hello, this is sample text",
url: "https://<yourdomain>.com/sms_status/"
}
).then(function (response) {
console.log(response);
});
})();
Give the phone number N:notification title to send a notification to your phone, instead of sending a SMS message.