Sending message from python using msg91

Below is tested code which can be used for sending the sms(message) from python application. As a pre-requisite you need to have an account on http://control.msg91.com

import urllib
import urllib.request
import urllib.parse
class sendmessage:
    @staticmethod
    def send_sms(mobile,message):
       authkey = '53535353535dfsfsdaagagaga' // api key created from http://control.msg91.com
       route = '4'                              // 4 is used to send the transational message other type can be used defined by msg91
       sender = 'TSTEST'                        // This is id which will be used in sms sent to users
       mobiles = mobile                         // you can have more than one comma seperated mobile numbers
       # Prepare you post parameters
       values = {
           'authkey': authkey,
           'mobiles': mobiles,
           'message': message,
           'sender': sender,
           'route': route,
           'country':91
       }
       url = "http://api.msg91.com/api/sendhttp.php"  # API URL
       postdata = urllib.parse.urlencode(values)  # URL encoding the data here.
       postdata = postdata.encode('utf-8')
       req = urllib.request.Request(url, postdata)
       response = urllib.request.urlopen(req)
       output = response.read()  # Get Response
       return

One thought on “Sending message from python using msg91

  1. BryanExami says:

    Immerse yourself in the world of cutting-edge technology with the global version of the POCO M6 Pro, which combines advanced features, stylish design, and an affordable price. This smartphone is designed for those who value speed, quality, and reliability.

    Why is the POCO M6 Pro your ideal choice?

    – Powerful Processor: The octa-core Helio G99-Ultra delivers lightning-fast performance. Gaming, streaming, multitasking—everything runs smoothly and without lag.

    – Stunning Display: The 6.67-inch AMOLED screen with FHD+ resolution (2400×1080) and a 120Hz refresh rate offers incredibly sharp and vibrant visuals. With a touch sampling rate of 2160 Hz, every touch is ultra-responsive.

    – More Memory, More Possibilities: Choose between the 8/256 GB or 12/512 GB configurations to store all your files, photos, videos, and apps without compromise.

    – Professional Camera: The 64 MP main camera with optical image stabilization (OIS), along with additional 8 MP and 2 MP modules, allows you to capture stunning photos in any conditions. The 16 MP front camera is perfect for selfies and video calls.

    – Long Battery Life, Fast Charging: The 5000 mAh battery ensures all-day usage, while the powerful 67W turbo charging brings your device back to life in just a few minutes.

    – Global Version: Support for multiple languages, Google Play, and all necessary network standards (4G/3G/2G) makes this smartphone universal for use anywhere in the world.

    – Convenience and Security: The built-in fingerprint sensor and AI-powered face unlock provide quick and reliable access to your device.

    – Additional Features: NFC, IR blaster, dual speakers, and IP54 splash resistance—everything you need for a comfortable experience.

    The POCO M6 Pro is not just a smartphone; it’s your reliable companion in the world of technology.

    Hurry and grab it at a special price of just 15,000 rubles! Treat yourself to a device that impresses with its power, style, and functionality.

    Take a step into the future today—purchase it on [url=https://ify.ac/1Y26]AliExpress[/url]!

Leave a Reply

Your email address will not be published. Required fields are marked *