Free SMSes through Google Calendar by http://www.kryogenix.org

This is a simple python code  for send  sms from google calendar via gdata api

# Requires gdata.py-1.2.1 from http://code.google.com/p/gdata-python-client/
from xml.etree import ElementTree
except ImportError:
from elementtree import ElementTree
import gdata.calendar.service
import gdata.service
import atom.service
import gdata.calendar
import atom
import base64
import time

def send_sms(message_text):
cal_client = gdata.calendar.service.CalendarService()
cal_client.email = "YOUR GOOGLE MAIL ACCOUNT"
cal_client.password = "YOUR GOOGLE MAIL PASSWORD"
cal_client.source = 'calendar-sms-misuse-1.0'

event = gdata.calendar.CalendarEventEntry()
event.title = atom.Title(text=message_text)
event.content = atom.Content(text="")

# can't set SMS reminders for under 5 minutes, so set this to 6 mins from now
start_time = time.strftime('%Y-%m-%dT%H:%M:%S.000Z', time.gmtime(time.time()+(6*60)))
end_time = time.strftime('%Y-%m-%dT%H:%M:%S.000Z', time.gmtime(time.time() + 3600))
when = gdata.calendar.When(start_time=start_time, end_time=end_time)
# can't set SMS reminders for under 5 minutes, so set this to 5
reminder = gdata.calendar.Reminder(minutes=5, extension_attributes={"method":"sms"})

cal_client.InsertEvent(event, '/calendar/feeds/default/private/full')

send_sms("Message body")

Original Post

No comments:

Post a Comment