Created
June 22, 2016 11:59
-
-
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.
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
#!/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