Skip to content

Commit

Permalink
Send text and make a call using Twilio
Browse files Browse the repository at this point in the history
  • Loading branch information
ramxpa committed May 30, 2012
0 parents commit 787a595
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions sendtext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import tweepy
from twilio.rest import TwilioRestClient


# == OAuth Authentication ==
#
# This mode of authentication is the new preferred way
# of authenticating with Twitter.

# The consumer keys can be found on your application's Details
# page located at https://dev.twitter.com/apps (under "OAuth settings")
consumer_key=""
consumer_secret=""

# The access tokens can be found on your applications's Details
# page located at https://dev.twitter.com/apps (located
# under "Your access token")
access_token=""
access_token_secret=""

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

#Twilio creds
account = "abc"
token = "xx"
client = TwilioRestClient(account, token)


class StreamListener(tweepy.StreamListener):
# status_wrapper = TextWrapper(width=60, initial_indent=' ', subsequent_indent=' ')

def on_status(self, status):
try:
message = client.sms.messages.create(to="+17077262685", from_="+14155992671",
body=status.text)

call = client.calls.create(to="17077262685", from_="+14155992671",
url="http:https://foo.com/call.xml")

except Exception, e:
# Catch any unicode errors while printing to console
# and just ignore them to avoid breaking application.
pass

streamer = tweepy.Stream(auth=auth, listener=StreamListener(), timeout=3000000000 )
setTerms = ['@ramanujam']
streamer.filter(None,setTerms)








0 comments on commit 787a595

Please sign in to comment.