Question About Using Python to Post to Twitter
-
What is the easiest way to automate a daily twitter status update with an image? The project is a twitter account that is counting down to a future event.I am working to create a daily update for my twitter account using python. Right now I'm running it off my computer, but the eventual goal is to host it online somewhere virtually. I was able to set up a daily update using http://www.tweepy.org/ and http://www.dototot.com/how-to-write-a-twitter-bot-with-python-and-tweepy/, which posts an update to the twitter account from each successive line in a text document. The https://github.com/andyratto/Twitter-election-countdown/blob/master/TwitterPythonFromFile, for text only. I couldn't figure out if Tweepy can also post an image along with the text update. Is there an easy way to attach an image that corresponds to each line/message in the text file? I was able to set up a status update with an image using https://twython.readthedocs.org/en/latest/, and http://twigstechtips.blogspot.com/2013/09/pythontwitter-posting-tweets-with-images.html. The https://github.com/andyratto/Twitter-election-countdown/blob/master/TwitterPythonwithImage, for a status update with an image. Is there a way that I can use this code but set up a list of status message and corresponding images that could be posted on a daily basis? I'm basically trying to combine the two different twitter python projects that I have working. One project can post once a day with a successive line from a text file, which can be used to do a text countdown in my twitter account. But I'm not sure how to add an image in. The other project sends a status update with an image, but I'm not sure how to go about automating it so that it can do the daily update as part of a countdown. What would be the next step, in terms of setting up a python script that will update my twitter account once a day with a text status and image for my daily countdown? Thanks!
-
Answer:
The easiest way is probably something like https://ifttt.com/recipes/search?q=daily+tweet&ac=false. If you want to keep going the Python way, you can schedule tasks with https://help.ubuntu.com/community/CronHowto. And you would probably have to modify your text file to come up with some way to specify image URLs and have the Python parse that out. For example, delimiting them with some special character like pipe | and then splitting the line on that character.
andoatnp at Ask.Metafilter.Com Visit the source
Other answers
If you'd like to avoid programming, you could try the aforementioned https://ifttt.com/recipes or the more business-focused http://zapier.com. Both let you use a "trigger" event to create an action somewhere else (e.g. on Twitter). Not sure how either of those would handle photos, though. Your posting pattern seems like it might also be easily achieved with a dedicated tool like https://hootsuite.com/plans/free.
reeddavid
you could just take the code from the second (twython) snippet and put it in the first (tweepy) snippet so that it's called in the loop. but having a program that runs for days is not a good idea. what if you want to restart the machine, for example? so it's better to use a cron job as mustardayonnaise suggests. use cron to run a program that reads the information from a file, posts to twitter and, importantly, then deletes that line from the file. so that the next day, when it runs again, it gets the next line. to be honest i am bit confused about what you are finding hard in all this. do you not know how to program? if not, then maybe you need to take a few days off and work through an introduction to programming in python. i would recommend http://learnpythonthehardway.org/. just a few days hard work will, i hope, give you a bit more confidence about what to do.
andrewcooke
http://www.billthelizard.com/2013/12/creating-twitter-bot-on-google-app.html I have used this for Twitter bots.
grobstein
Related Q & A:
- how to zip similar files using python?Best solution by Stack Overflow
- How to add image to QTextBrowser using Python?Best solution by Stack Overflow
- How to verify a JWT using python PyJWT with public key?Best solution by Stack Overflow
- How to create a graph using python?Best solution by Stack Overflow
- How to Creating text File using Python?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.