Retweeting the Right Way

Retweet Shirt Photo by Deb Hanson -

Just released an update to ReTweeter (1.1), which now uses the Twitter API for Retweeting. This means that instead of the traditional “RT: @username” syntax, the retweeted tweets will now show Twitter’s little retweet icon and the link to the original tweet (where it says “about 4 hrs ago”) preserved, and the retweeting user’s name at the bottom, like so:

Screencap by Jeronimo Palacios -

Instead of what Retweeter used to produce, which looked more like this (rt: @username):

Or this (username: tweet):

Thanks to Cody Wilson at QC Co-Lab (@qccoloab) for the patch for this. Of course, if you’d like to keep the old format, you can just set ‘USE_OLD_FORMAT’ to true in the configuration section, and retweeter will keep using the older format.

I’ve also started storing the md5 hash (required for OAuth) in the database instead of recalculating it each time retweeter gets called. (If you ever need to change your md5 hash, say because you’ve regenerated your OAuth token at Twitter, just delete the row in the ‘conf’ table and retweeter will create a new hash the next time it runs).

Note that you will have to alter database tables if you’ve previously used a version of ReTweeter from 1.0 or before – but I’ve included the necessary SQL statements in the README included with the download.


  1. Did you post a download link somewhere in there and I missed it? I found the new version by following the link in the previous post about retweeter and changing the version number. I don’t see this project on your code page. Are there any plans to host it on github or google code?

    I’m about to give it a go on the @WPBook account so we can pull in the #wpbook hash tag. I’ll let you know how it goes.

    This looks like something fun/useful to play around with. Thanks John!

  2. Sorry for the comment spam but I found a bug. I kept getting this error “Could not select tweets not tweetedUnknown column ‘PlainPostID’ in ‘field list'” looks like in the SQL statement in the readme you have “PostPlainID” instead of “PlainPostID” I changed the SQL instead of the code but either one would work.

    Also a suggestion would be in the retweeter.php change “$consumer_request” to “$consumer_secret” as I was trying to figure out if you wanted the secret or Request token URL

    Again sorry for the comment spam and it looks like I got everything up and running!

  3. Thanks for catching that – I will update the SQL statements in the readme. I created those after the fact and didn’t notice I’d transposed Post and Plain!

  4. Updated retweeter 1.1 – just fixed the SQL statements in the readme and replaced the existing 1.1, so use the same download link.

    Hadn’t thought about putting this on Google Code or GitHub as I thought it would be kind of a one time hack – but if there’s interest in continuing to develop it (perhaps even adding a web interface for entering config info, and doing a true OAuth exchange with Twitter) I would certainly be up for it.

  5. When I was installing this I was thinking “It sure would be nice to have a web interface” and also thought that about logs and such. I just don’t know if I’ll ever find the time to write one or that you want me following you around and geting invovled with all your project :)

  6. Thank you for the application, it is just what I was looking for. However, I am getting this:
    Results of Tweeted is NULL query: 1

    Re-tweet failed, with status code 401

    i have the correct auth parameters:
    consumer_key and consumer_request
    retweeter_oauth_token and retweeter_oauth_secret

  7. @Sam F – Not sure what that might mean.

    Status code 401 should mean an authorization error according to Twitter API.

    Is it a consistent failure or intermittent?

    When you set up your application at Twitter’s site, did you make it an application that can post as well as read from your stream?

  8. Thank you for your reply!
    I was not able to figure it out, I created another app and it worked without the error code.

    However, there is something I noticed and wish to request for the next release:

    -When the application retweet, it takes some topic and use “rt: @username….” but what is happening is that this action is ending up as such:
    rt: @username rt: @username rt: @username rt: @originalusername…..(the rest of the tweet).
    -Having the possibility to specify a hashtag (or multiple) separately from the username. That way the query can be more precise.

    In the end, I really appreciate your effort in making this open to users like me and others around the web.


  9. Hi!

    I’m finding the same problems with authentication:

    Re-tweet failed, with status code 401

    I created several app and follows the same mistake.

    I’m using the version 1.1: Is there anything new you should know to solve this problem?

    Thanks and good work!

  10. Hi!

    Yes, I upgraded to version 1.1.1

    And I set the fields: consumer_key, consumer_secret, oauth token, and oauth secret

    I have my twitter app created with read & write … I do not get run code
    by 401. Twitter has changed a policy of oauth


  11. @dtonante

    Sorry, not sure how I can help. It’s working for others, so I suspect the error is in your configuration somewhere.

    When you say “Twitter has changed a policy of oauth” what are you referring to?

    When you say “I do not get run code by 401” do you mean you are getting a 401 error when you try to run the code?

    Does retweeter successfully retrieve tweets and add them to your database? What is the full output of the script?

Comments are closed.