Skip to content

Instantly share code, notes, and snippets.

@surajnarwade
Created June 22, 2016 11:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save surajnarwade/381f7e6b4bdf21c3e6dc423b40d09416 to your computer and use it in GitHub Desktop.
Save surajnarwade/381f7e6b4bdf21c3e6dc423b40d09416 to your computer and use it in GitHub Desktop.
As a Social media Volunteer to Pycon India, we have to share every word by @pyconindia on twitter, so I automated this task by writing following script.
#!/bin/python
import tweepy
#following Oauth credentials can be obtained by creating twitter app
cfg = {
"consumer_key" : "<consumer_key>",
"consumer_secret" : "<consumer_secret>",
"access_token" : "<access_token>",
"access_token_secret" : "<access_token_secret>"
}
def get_api(cfg):
auth = tweepy.OAuthHandler(cfg['consumer_key'], cfg['consumer_secret'])
auth.set_access_token(cfg['access_token'], cfg['access_token_secret'])
return tweepy.API(auth)
def main():
api = get_api(cfg)
while True:
for status in api.user_timeline('pyconindia'):
current_status_id = status.id
print current_status_id
break
retweet_status = api.get_status(current_status_id).retweeted
print retweet_status
if retweet_status:
print("already retwitted")
else:
print("retweeting")
api.retweet(current_status_id)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment