Created
June 3, 2013 15:04
-
-
Save gabalese/5698842 to your computer and use it in GitHub Desktop.
Quick and dirty script to post a tweet from the CLI interface. Requires twitter library.
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
#! /usr/bin/env python3 | |
from twitter import * | |
import os, sys | |
CONSUMER_KEY = <your_consumer_key> | |
CONSUMER_SECRET <your_consumer_secret_key> | |
MY_TWITTER_CREDS = os.path.expanduser('~/.token_cache') | |
if not os.path.exists(MY_TWITTER_CREDS): | |
try: | |
oauth_dance(<your_app_name>, CONSUMER_KEY, CONSUMER_SECRET, MY_TWITTER_CREDS) | |
except Exception as e: | |
print("IMPOSSIBILE AUTENTICARE.") | |
print(e) | |
sys.exit(2) | |
oauth_token, oauth_secret = read_token_file(MY_TWITTER_CREDS) | |
twitter = Twitter(auth=OAuth(oauth_token, oauth_secret, CONSUMER_KEY, CONSUMER_SECRET)) | |
if __name__ == "__main__": | |
if len(sys.argv) < 2: | |
print(twitter.statuses.home_timeline()) | |
else: | |
twitter.statuses.update(status=sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment