.



Twitter API - How to send tweets from a Wordpress “Tweet this” button


Tweet This feature - My Life Sucks … Big Time !!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 !!!:

Tweet This form - 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:

Tweet This result - My Life Sucks … Big Time !!

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!


Feed for this Entry
Trackback Address

15 Responses to “Twitter API - How to send tweets from a Wordpress “Tweet this” button”


  1. 1 Richard X. Thripp

    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.

  2. 2 Twitter Search

    thats great that you are talking about the twitter api,a good example of searching with the twitter api is on twiogle.com because you can search on twitter and google at the same time.

  3. 3 bodydetox

    Twitter is very addictive. I like Twitter more than blogging. the messages are short and straight to the point.

  4. 4 francio

    What is Twitter and How Can I Use Twitter?

  5. 5 acnetreatmentsguy

    i really love to use Twitter. i was addicted to Blogging before the birth of Twitter. Now i am addicted to Twitter.

  6. 6 Cleothildee

    i love to Twitter my day to day activities to my friends and followers. Twitter is much better than blogging because it is direct to the point and does not require you to type so many unnecessary words.

    1a

  7. 7 Kristine Shuee

    - i just love to Twitter everyday with my friends. Twitter is much better than blogging in my opinion and it is very addictive too.
    * *

  8. 8 Caramoan

    Twitter is some ways is much better than blogging. I love to Twitter my everyday activities on my friends and relatives.
    ***

  9. 9 Mayme Schoenhals

    Hello I am so delighted I found your blog, I really found you by mistake, while I was looking on Yahoo for something else, Anyways I am here now and would just like to say thanks for a tremendous post and a all round entertaining blog (I also love the theme/design), I don’t have time to read it all at the moment but I have bookmarked it and also added your RSS feeds, so when I have time I will be back to read more, Please do keep up the great work.

  10. 10 tweet adder coupons

    Starting new to twitter may be daunting but when you genuinely use it as the powerful marketing tool it can be it will certainly pay off in the long run. I believe twitter is a great way to drive traffic to your site.

  11. 11 Ken Santos

    Twitter is really a good way in keeping yourself updated with the day to day activities of your friends and families members. I update my Twitter and personal blog daily.

  12. 12 Mubbasahr

    Hi to all.Is there any way to authorize user with “sign in with twitter” and than update their status.If you have any solution than please tell me.
    Thanks in advance
    Regards
    Mubbashar

  1. 1 CabEasy.com - Up and running ?
  2. 2 links for 2009-04-02 « boblog
  3. 3 Integrate Twitter Buttons in Wordpress (with shortened URL) | cathycracks.com

Leave a Reply






PercentMobile Tracking