Twitter API code
import tweepy
from tweepy import OAuthHandler
from tweepy import Stream
import requests
consumer_key = '***'
consumer_secret = ‘***'
access_token = '***'
access_secret = ‘***'
last_tweet = ''
#twitter_user = 'realDonaldTrump'
twitter_user = 'EvanAdkins88'
#Monitor specified user's twitter posts
while (True):
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth)
#Colect most recent post on user's wall
tweets = api.user_timeline(screen_name = twitter_user, count = 1)
#Check if most recent tweet contains an '!'
if (tweets[0] != last_tweet):
last_tweet = tweets[0]
print(tweets[0].text)
if ('!' in tweets[0].text):
print ('SAW !')
requests.post("https://maker.ifttt.com/trigger/tweet_recieved/with/key/bbVY04YYbiLvYn8Jea_L0B")
else:
print ('SAME TWEET')
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .