Created
March 12, 2016 11:12
-
-
Save anonymous/648a12eeae073989f5bf to your computer and use it in GitHub Desktop.
Código para enviar twitter com imagem
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
def __init__ (self): | |
self.consumer_key = "" | |
self.consumer_secret = "" | |
self.access_token = "" | |
self.access_token_secret = "" | |
auth = tweepy.OAuthHandler(self.consumer_key, self.consumer_secret) | |
auth.secure = True | |
auth.set_access_token(self.access_token, self.access_token_secret) | |
self.api = tweepy.API(auth) | |
def get_twitts(self): | |
print self.api.me().name | |
for item in self.api.home_timeline(): | |
print u'%s' % item.text | |
def post(self, message=None, image=None): | |
# Method to post new twitt | |
if message: | |
try: | |
if image: | |
self.api.update_with_media(filename=image, status=u'%s' % message) | |
else: | |
self.api.update_status(status=u'%s' % message) | |
except Exception as e: | |
print e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment