manniru
4/29/2014 - 11:07 AM

twiliotemp2.py

from twilio.rest import TwilioRestClient


class TwilioSMS:

    def __init__(self):
        self.account_sid = "AC0b56c1b6b1ff87e0caaf2c41ee5a7380"
        self.auth_token = "d788a0bac58674a4efdd8fdb86c201a6"

    def viewsms(self):
        client = TwilioRestClient(self.account_sid, self.auth_token)
        sms = client.sms.messages.get("SM0aa437df1e14e2fbbc385ee2988c1cdb")
        return sms.body

    def makeCall(self):
        client = TwilioRestClient(self.account_sid, self.auth_token)

        call = client.calls.create(to="+2348033099431",
                           from_="+14242851118",
                           url="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient")
        return call.sid

    def sendSMS(self, phone, message):
        client = TwilioRestClient(self.account_sid, self.auth_token)

        message = client.messages.create(to = phone, from_="+14242851118", body=message)
        return message

twilio = TwilioSMS()

#print twilio.viewsms()
#print twilio.makeCall()
print twilio.sendSMS('+2348033099431', 'Twilio SMS Test from Google Appengine from Python')