I just posted that I installed a new feature that I called “Tweet This” on My Life Sucks … Big Time !!!. It allows a visitor to post a twitter message directly from the website, and tweet the link to the post.
I didn’t find that wordpress feature/plugin on the web (did I miss it ?), so I had to develop it myself. It’s a fairly trivial piece of code, and it’s actually more about putting things together. I’ll try to describe the process below. WARNING: I am not a developer, I am an amateur, the code might not be clean, so please comment to improve !
1) Prerequisite: you need the Thickbox plugin installed and working. I prefer adding a thickbox layer than opening a popup.
2) Understand how the Twitter API works. You can start here, and continue here.
3) Get a good script. I used this one from a guy called Gareth Rushgrove, as it’s php+curl and works well.
4) Modify the script: for the moment it just encompasses the “update twitter” part. You’ll need to create a form that includes three fields: the user twitter’s login and password and his message. I used only one file to do that: it first checks if the form was submitted - if Yes, it sends the update to twitter and tells me if it succeeded ; if No, it displays the form.
Download my version of the script here (note: no css, no javascript).
Remember to receive the permalink of the article in the textarea:
<textarea….>Excellent: <?php echo $_GET[’link’]; ?></textarea>
This is the result I on My Life Sucks … Big Time !!!:
5) Insert the link in your Wordpress files. I decided to align it after the post title (in theloop.php). For the ThickBox, I used the iFrame option to make sure things would run smoothly (as twitter.php reloads). Insert any argument before the ThickBox arguments.
If you copy paste this link, it should work:
<a href="PATH_TO_SCRIPT/twitter-update.php?link=<?php the_permalink(); ?>&keepThis=true&TB_iframe=true&height=320&width=550" class="thickbox">Tweet this !</a>
You’re done !
6) Add some cosmetics (optional) with css formating in your file as well as some javascript code to determine the number of characters in the message (140 per tweets!).
Here is what appears on my Twitter account:
Again, I am an amateur. So please do comment with any update/improvement/advice/rant I should include !
If you enjoyed this post, make sure you subscribe to my RSS feed
or receive my posts by email !


Wow, awesome! I totally came up with Tweet This way after you and stole your name inadvertently. It’s a good idea. Sharing blog posts on Twitter takes too many steps normally.