Created
January 31, 2015 11:48
-
-
Save pleonex/a532ae3be3fd87e124c3 to your computer and use it in GitHub Desktop.
Gets the text from file and publish into several tweets.
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 | |
# -*- coding: UTF-8 -*- | |
import twitter | |
CONSUMER_KEY = "" | |
CONSUMER_SECRET = "" | |
TOKEN_KEY = "" | |
TOKEN_SECRET = "" | |
FILE = "filename" | |
api = twitter.Api(consumer_key=CONSUMER_KEY, | |
consumer_secret=CONSUMER_SECRET, | |
access_token_key=TOKEN_KEY, | |
access_token_secret=TOKEN_SECRET) | |
status = api.PostUpdate("HOLA CHICOS, NUEVO TEMA: " + FILE) | |
print status.text | |
# Get the text | |
with open(FILE, 'r') as f: | |
presentation = f.read() | |
# Divide 140 chars and publish | |
num_tweets = len(presentation) / 140 | |
for i in range(num_tweets): | |
end_pos = (i + 1) * 140 | |
if end_pos > len(presentation): | |
end_pos = len(presentation) - 1 | |
tweet = presentation[i*140:end_pos] | |
try: | |
status = api.PostUpdate(tweet) | |
print status.text | |
except: | |
pass | |
print "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment