Did you know that the google calendar can send SMS reminders? Probably yes. I use it all the time. Did you know that with the help of such reminders you can make yourself an SMS alert? But you can. A kind of personal free SMS gate. I read about it a long time ago, but then I didn’t need it. Recently it was required to send SMS alerts from a piece of iron ala smart home and I remembered about this method. I remembered, I found a ready-made django module that implements it, and connected it to my site. Works! It all took me about half an hour. But first things first.
He recently told my good friend that they say he got himself a piece of iron to which you can connect different sensors. Zhelezyaka will interrogate these sensors and report problems in the house (at the cottage). For example, thieves got into the room, flooded the basement, or the toilet paper runs out (and why not? Such a sensor can save you from a most unpleasant incident).
But there is only one problem: the piece of iron is ancient and does not know how to go over https, and all SMS gates (what he saw) have only the https API. I, without hesitation, made http proxy on my site. Everything works, the proxy goes to Google as a young one, changes https to http, everyone is happy. And here and there, it turned out that everything is not so simple with providers. It’s expensive, only for corporate clients, they don’t give API to everyone ... In general, my friend didn’t grow together with gates. I taught him to admin proxy and safely forgot about it.
For several days this thing was spinning in my subconscious (apparently) and just yesterday I got out of there with the words “Google Calendar can send SMS and it has an API. Do you remember we read about this for a long time? ” I got into Google, found a jango module, added it to the site, tested sending (it works!), Finished trochs and made my friend happy. Let him use, I do not mind.
')
How to connect
Enough lyrics. Practice.
IVIlych ,
pointed to a simpler way, without dancing with the calendar.
It turned out that the site sms.ru for several years provides free SMS for programmers.
Registration takes place on a mobile phone number, no SMS should be sent to do this. Only the verification code will be sent to the number.
After registration, you can send up to 60sms per day to your number specified during registration. For almost a month, I have transferred all my services from Google to this service. Pleases the absence of a minute delay before sending and the possibility of receiving the status of the message.
You can send in different ways, on the website, in the section "Programmers" there are many ready-made examples:
- HTTP
- curl for command line (UTF-8)
- php (with curl enabled)
- php (without curl)
- php (strong authorization)
- PERL (strong authorization)
- Python
The easiest way is to open the page:
sms.ru/sms/send?api_id=xxxx-xxxx-xxxxx-xxxx-xxxx&to= phone_number&text=hello+worldwhere - xxxx-xxxx-xxxxx-xxxx-xxxx is the id available after registration.
It is also possible to send email by SMS. In the "Mail sms.ru" section you can set up your mailbox name@sms.ru letters to which will be sent to your phone as an SMS. When the option “cut to 1cm” is enabled, all messages to your number will be free.
The note about sms.ru is taken from the post of the
Wida browser:
Sending a free sms message in linux .
You can create a reminder event via the
Google API . This is a regular post request with OAuth2.0 authorization and JSON parameters in BODY. Right on the link, you can try to create a reminder in your calendar. There are customers for
many platforms .
But we have Django. In which there is a module django-calendar-sms. Which is easy to install and configure:
pip install django-calendar-sms
- Add the
calendar_sms
application to INSTALLED_APPS
in the settings file (usually settings.py) - Sync database
./manage.py syncdb
- After that we go to the Django admin area, set up Google account and calendar data.
Everything, you can send yourself an SMS directly from the django console (
./manage.py shell
):
>>> from calendar_sms.sms import sendSMS >>> print sendSMS('Hello, World!')
Here is the code of my django view, which sends SMS (
view code on GitHub ):
def send(request): secret = request.GET.get('secret') text = request.GET.get('text') if not secret or secret != SMS_SECRET or not text: raise Http404 try: r = sms.sendSMS(text) or "Sent"
What's next?
I plan to change this code, as it does not suit me that from one django site you can send SMS only to all users at once. I want SMSs to go away to me and to my friend separately.
I also want to connect my wife to this gate to make it easier to send SMS messages when roaming from business trips. Maybe even an android application for this will do. Who knows.
Can you tell something else? It would be interesting to hear what else can be done with such a thing. There is only one restriction: the SMS recipient must first be registered in the system.
UPD: IVIlych ,
pointed to a simpler way, without dancing with the calendar.
It turned out that the site sms.ru for several years provides Free SMS for programmers.
You can send yourself an SMS using the usual GET request:
sms.ru/sms/send?api_id=xxxx-xxxx-xxxxx-xxxx-xxxx&to= phone_number&text=hello+worldwhere - xxxx-xxxx-xxxxx-xxxx-xxxx is the id available after registration.