22👍
Hi my name is Jarod and I work for Twilio.com so I am a little biased. But with that said, it is super easy to send an SMS from your Python web application using the Twilio Rest Api. Here is a simple example:
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioRestClient
# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "{{ account_sid }}"
auth_token = "{{ auth_token }}"
client = TwilioRestClient(account_sid, auth_token)
message = client.messages.create(
body="Jenny please?! I love you <3",
to="+15558675309",
from_="+14158141829",
media_url="http://www.example.com/hearts.png")
print message.sid
11👍
From a technical standpoint, the easiest way to accomplish SMS sending with any web-app is through e-mails. Most cell providers usually give out email accounts to their users, and sending a mail to said account will more likely than not redirect the mail to their cell via SMS. However, not all carriers do this and some charge extra for this type of service. In this case, you could handle this checking out the following Django documentation page
However, as mentioned, this isn’t a really complete solution, so the easiest way would be to use a SMS-gateway. Mostly, they provide simple REST based API’s for sending text messages to cell phones. The API would vary obviously from carrier to carrier. I would recommend checking out Kannel in case you’re looking for a free and open source solution (that is assuming you want to install the actual gateway on your server).
Anyway, I would start out trying to get it to work with the e-mail scenario, and then moving on to using a carrier if you actually require it. Hopefully this helps somewhat.
- [Django]-Django urlsafe base64 decoding with decryption
- [Django]-Testing nginx without domain name
- [Django]-Get Timezone from City in Python/Django
4👍
I answered a similar question, a bit late to the game, in another post. Here it is for additional information. Hope it helps:
I was struggling with this for some time and really liked the Twilio option. But then I dug deeper and found that there is a Google Voice API called pygooglevoice
that works. Clean, easy… No carrier lookup… For example, set up a virtualenv
and install with pip
:
pip install pygooglevoice
Then use something like this:
from googlevoice import Voice
from googlevoice.util import input
def send(number, message):
user = 'user@gmail.com'
password = 'password'
voice = Voice()
voice.login(user, password)
#number = input('Number to send message to: ') # use these for command method
#message = input('Message text: ')
voice.send_sms(number, message)
Please note that I have done limited testing with this so I’m not sure all the pros and cons. It’s quite possible that there are limitations I haven’t discovered yet. But in the time I’ve played around with it, I’ve been happy.
- [Django]-Get list item dynamically in django templates
- [Django]-Django-reversion and related model
- [Django]-Django dynamic forms – on-the-fly field population?
- [Django]-Django 1.8 KeyError: 'manager' on relationship
- [Django]-Troubleshooting Site Slowness on a Nginx + Gunicorn + Django Stack
- [Django]-How to use refresh token to obtain new access token on django-oauth-toolkit?
0👍
Check out twilio.com. They provide easy to use API (couple of lines of code in Python) and possibility to receive SMS messages and firing callbacks in your application when users respond.
- [Django]-Django: For Loop to Iterate Form Fields
- [Django]-How to deal with "SubfieldBase has been deprecated. Use Field.from_db_value instead."
- [Django]-Unittest Django: Mock external API, what is proper way?
0👍
http://bitbucket.org/vgavro/django-smsgate is obviously what you are looking for, but you have to write custom backend for your sms-gateway.
- [Django]-Django: Open uploaded file while still in memory; In the Form Clean method?
- [Django]-Homepage login form Django
- [Django]-Macros in django templates
0👍
I have also found TextMagic. It looks promising although it is a bit pricey for the country I live in. It may have competitive prices for the country you are interested in, so please check pricing before you charge ahead.
Usage seems to be easy enough:
Quick installation via pip:
pip install textmagic
And sending an SMS seems to be trivial as follows:
from textmagic.rest import TextmagicRestClient
username = "your_textmagic_username"
token = "your_apiv2_key"
client = TextmagicRestClient(username, token)
message = client.messages.create(phones="9990001001", text="Hello TextMagic")
- [Django]-How to customize activate_url on django-allauth?
- [Django]-Django Cache cache.set Not storing data
- [Django]-Default value for user ForeignKey with Django admin