Example api code for Promotional SMS in python

Replace user, password, msisdn, sid and message accordingly.

 

1. Below is the sample code for python for Single Message:

import requests

user = 'abc'
password = 'xyz'
msisdn = '919898xxxxxx'
sid = 'SenderId'
message = 'test message'
fl = '0'

url = f'http://sms.domainadda.com/vendorsms/pushsms.aspx?user={user}&password={password}&msisdn={msisdn}&sid={sid}&msg={message}&fl={fl}'

try:
response = requests.get(url)
response.raise_for_status() # Raise an exception for 4xx and 5xx status codes
print('API response:', response.text)
except requests.exceptions.RequestException as e:
print('Error sending request:', e)

 

2. Below is the sample code for python for Multiple Messages:

import requests
import urllib.parse

user = 'abc'
password = 'xyz'
msisdns = '919898xxxxxx,919898xxxxxx' # Comma-separated list of phone numbers
sid = 'SenderId'
message = 'test message'
fl = '0'

# Encode the parameters
params = urllib.parse.urlencode({
'user': user,
'password': password,
'msisdn': msisdns,
'sid': sid,
'msg': message,
'fl': fl,
})

url = f'http://sms.domainadda.com/vendorsms/pushsms.aspx?{params}'

try:
response = requests.get(url)
response.raise_for_status() # Raise an exception for 4xx and 5xx status codes
print('API response:', response.text)
except requests.exceptions.RequestException as e:
print('Error sending request:', e)

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Example api code for Promotional SMS in php

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Promotional SMS in asp.net

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Promotional SMS in java

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Promotional SMS in ruby

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...

Example api code for Promotional SMS in node,js

Replace user, password, msisdn, sid and message accordingly.   1. Below is the sample code for...