Developer Tools
BasicText SMSCampaignSendOTPVirtual NumberResellerSample CodePhonebookError Code
HOME LOGIN SIGN UP
  • Send SMS in PHP
  • Send SMS in Python
  • Send SMS in JAVA
  • Send SMS in JAVA For XML API
  • Send SMS in C#
  • Send SMS in Google Appscript
  • Send SMS in Windows 8
  • Send SMS in Android
  • Send SMS in iOS
  • Send SMS in VB6
  • Send SMS in Oracle
  • Send SMS in Go Language
  • Api Postman Collection

Python Sample Code Send SMS

Code:

import urllib # Python URL functions
import urllib2 # Python URL functions
authkey = "YourAuthKey" # Your authentication key.
mobiles = "9999999999" # Multiple mobiles numbers separated by comma.
message = "Test message" # Your message to send.
sender = "112233" # Sender ID,While using route4 sender id should be 6 characters long.
route = "default" # Define route
# Prepare you post parameters
values = {
'authkey' : authkey,
'mobiles' : mobiles,
'message' : message,
'sender' : sender,
'route' : route
}

url = "http://api.msg91.com/api/sendhttp.php" # API URL
postdata = urllib.urlencode(values) # URL encoding the data here.
req = urllib2.Request(url, postdata)
response = urllib2.urlopen(req)
output = response.read() # Get Response
print output # Print Response

© 2008-2025 | All Rights Reserved.