Skip to content

Instantly share code, notes, and snippets.

Created March 12, 2016 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/648a12eeae073989f5bf to your computer and use it in GitHub Desktop.
Save anonymous/648a12eeae073989f5bf to your computer and use it in GitHub Desktop.
Código para enviar twitter com imagem
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