-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send text and make a call using Twilio
- Loading branch information
0 parents
commit 787a595
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|