Making Tweet-Based WordPress Posts Easier: Hacking “Twitter Digest”

Before my recent blogging hiatus, I was using an only slightly hacked version of the WordPress Twitter Digest plug-in to put together posts collecting my twitter traffic. I stuck for a couple of months with what amounted to a one-sided version of my twitter time-line, and, in trying to close in on what I had envisioned, I found myself spending inordinate time and energy concocting summaries, and collecting and formatting images. I considered various methods for refining the output, and expect still to work up an improved version of the plug-in, but in the meantime I stumbled upon an easy way to turn the plug-in into a tool for quickly turning tweets into blog posts. I also have not yet gotten around to address the truncated RT issue that I’ve previously discussed.

What I wanted was an easy way to assemble recent tweets of interest – especially the kinds of tweets that, put together, construct arguments or outlines of arguments potentially worth discussing further or expanding upon more intensively. For now all I want is a tool for collecting tweets quickly and having them automatically placed in a draft post, in a form that I can easily manipulate. Eventually, we’ll get to a slimmed-down version with only the code we need, amounting to an entirely separate plug-in – “Tweet-Poster” or something with its own tailored dashboard – but here’s the brute force hack, based on the assumption that you have already fully installed and set up Twitter Digest – though, just in case it doesn’t go without saying, hacking it this way means making it useless for its intended functions:

1) Open twitter-digest.php in the WordPress Plug-In Editor (i.e., Plugins/Editor/twitter-digest.php), or copy it into a code editor like NotePad++.

2) Scroll down to or search for the note “Was this tweet added in the time period of interest?”(around line 160).

3) Comment out the two if- statements. The results might look like this:

 /* --------begin hack------------
 //Was this tweet added in the time period of interest? 
 if ($tw_data->created_at < $startDate) {
 if ($tw_data->created_at > $endDate ) {
 -----------end hack-------------- */

4) Save the file in the Plug-In Editor.

5) Open Twitter Digest from under WordPress dashboard Settings

If Twitter Digest is already installed and working for you, you must have Twitter Account Info already filled out. If not, you’ll have to acquire the needed keys/codes/tokens before going any further.

Under “Publish Options” leave “Time of Day” blank, and handle the “Post Options” however you like. Give the post a title and, since you likely won’t want to have the “take” published automatically as is, set “Post Status” to “Draft.”

6) Enter number of tweets to retrieve

Note that we’re using this only as a tool for simplifying the retrieval of multiple relatively recent tweets: Twitter limits how many you can retrieve at a time to 200, so, if you’re interested in going further back, you’ll have to use some other method – like Storify or a Twitter Archive download – to get your tweets from even a few days ago.

Let’s say there was a series of tweets from around 50 tweets ago that you know you’re going to want to work with. Enter “100” after “Maximum number of tweets to retrieve,” just to give yourself a margin for error, then click “Update Options.”

7) Reset Database

Twitter Digest is set up to avoid duplication. Our future “Tweet Scraper” or “Tweet Poster” plug-in won’t need this feature, but, if you’ve done this already, or just to be safe, click “Reset Database.” Otherwise, the new retrieval will start (or end, depending on how you look at it) wherever the last one left off. (If you haven’t done any tweets since the last retrieval, you won’t get anything this time.)

8) “Ping Twitter”

Twitter Digest will tell us that a “Post containing yesterday’s tweets has been drafted,” and will tell us in green letters. In “Tweet Poster”‘s new dashaboard, I think we’d like to have it provide us with a link to the new post.

I’ll instead have to find it near the top of the Posts screen. Once I open it, I’ll have a list of my most recent 100 tweets in chronological order. It will be easy to delete the lines above and below the tweets I want, to produce a post or posts with the remaining material: Hack-Mission Accomplished.

10) Reset Options

If you leave our hacked Twitter Digest with the settings as above, it will continue to produce new draft posts continually, tweet by tweet, periodically. I’m not sure what initiates the retrieval, actually, and how it relates to behavior intended by the plug-in author. For the moment, I’m leaving “Minimum tweets required for a post” at “200,” and “Time of Day” under “Publishing Options” at “24:00.” I’m guessing that will prevent the unwanted post drafts from being created while I continue to research the matter.

Commenter Ignore Button by CK's Plug-Ins

Leave a Reply

Your email address will not be published. Required fields are marked *