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

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=""></script>

<!-- include the GMTweets library, keep this hosted to our servers to ensure you stay up-to date -->
<script src=""></script>

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

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

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


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.