Friday, 14 June 2013

Need help getting your tweets onto your website? (Twitter API v1.1 no PHP needed)

A lot of us used to use the old "search twitter for the screenname and return the json results" javascript.. this was awesome, and easy to implement.

Unfortunately, Twitter turned off the old 1.0 API, which includes unauthorized queries to their API v1.1.. now you have to sign up for an application, create an oAuth and make requests to twitter..

Now people are shouting "My twitter feed isn't working!!!" and "how do i get my twitter feed on my website?" and "how to oauth with twitter"...

This means time and hassle searching and developing.. it also means you need to watch and change it again once twitter change their setup again!

Or, you could use http://getmytweets.co.uk

It's simple, it includes 5 steps in total, and 1 of the steps is sharing the website with people!!

Here's how it works..

Simply, place this above the </head> tag of your HTML and replace "gmtweetsuk" with your twitter username..

<!-- include the jQuery library if you haven't already -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>

<!-- include the GMTweets library, keep this hosted to our servers to ensure you stay up-to date -->
<script src="http://api.getmytweets.co.uk/min.tweet.2.js"></script>

<!-- the plugin -->
<script type="text/javascript">
$(document).ready(function(e) {
    
    $('.twitter_feed').getmytweets({
        twitter_sn: 'gmtweetsuk', /* my twitter username */
        twitter_wrap: 'tweet', /* wrap each tweet with a class */
        twitter_limit: 1 /* how many tweets to return */
    });
    
});
</script>

And then place this where you want your tweets to appear:

<div class="twitter_feed"></div>

Simple!

The good thing about this, is when twitter change things, you don't have to! GMTweets will constantly update their API to keep your feed current and working.. all you need to do is keep linking to their JS.

2 comments:

  1. ERMERGERD!!! Thank You!!!!

    ReplyDelete
  2. Hi Danny,

    Thanks for this wonderful script. I have been searching for a while for a clever way to show my tweets on my website. I have actually one request regaring your script. Would it be possible to include the date and time in every tweet?
    Thanks for your support.

    Best regards,

    Frans
    http://zuiderburen.com/index_nieuw.php

    ReplyDelete