Question

I'm a (very) amateur coder and need help figuring out a problem I would like to implement for my Tumblr.

I have a folder of plain .txt files with each txt filename corresponding to a specific Post ID on my Tumblr.

I want to create something where the most recent Post ID can be automatically fetched once a day and used to replace a file name in an existing folder, so that the chain of events goes:

  1. I create file "/files/replace.txt"
  2. Code fetches the Post ID from the most recent post on my Tumblr (maybe at a specified time each day?)
  3. Code renames "/files/replace.txt" to "/files/{PostID}.txt"

Right now I'm doing this manually, which is becoming almost impossible to keep up with. Any ideas on how to execute this?

Thanks so much for your time!

Était-ce utile?

La solution

Where are the text files hosted? Your personal computer? A server somewhere?

This would be very easy to implement. Create a small script in the language of your choice (you've tagged the post as PHP) that makes a call to the Tumblr API. From there examples, you could retrieve a listing of your latest posts with a call like this:

 http://api.tumblr.com/v2/blog/YOURBLOG/posts/text?api_key=YOURAPIKEY

The script could then take the latest Post ID and rename replace.txt. Assuming this is running on a linux server, a simple CRON job would set this to run at any interval you wish (5 minutes? 5 hours? once a day?)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top