Display your FourSquare updates on your website
by leon on April 6, 2010
I recently made a few small changes to my personal website, including the addition of my most recent FourSquare check in’s. This post is a quick write up to show you how I did it for FourSquare, but this technique can be used for almost any social network or RSS feed.
You may be thinking – “Why not just use the widget they released?” – because it didn’t fit into the design or style of my site – plus with this I can pick and choose the information that is displayed.
Getting the updates onto my site was made easy by using the jFeed and timeago jQuery plugins.
First of all, go and grab the files from here and here.
The only files we really need from the jFeed download is the plugin itself located in build > dist > jquery.jfeed.pack.js and a file called proxy.php. Upload these and the jquery.timeago.js from the TimeAgo download to somewhere on your server and add a link to the head of your document.
Next, head over to the feeds section on Foursquare and copy the link to your RSS feed (it looks like the image below).

Next step is to create the Javascript to parse the feed. We need to pass this through the proxy.php file due to the fact that the file we are requesting is on a different server to the one we are calling it from. The read me documentation said that this shouldn’t be used – but what the hell I just ignored it!
Don’t forget to add your FourSquare feed in below!
$.getFeed({
url: 'proxy.php?url=YOUR FOURSQUARE FEED.rss',
success: function(feed) {
var html = '
- ';
for(var i = 0; i < feed.items.length && i < 5; i++) {
var item = feed.items[i];
html += '
- ' + '' + item.title + ' - ' + jQuery.timeago(item.updated); + ' '; } html += '
So to explain, the above Javascript passed the FourSquare RSS feed through the proxy.php and then creates a variable called html with an opening <ul> tag. Upon each iteration of the loop, upto a maximum of 5 the function then selects the title, link and when the checkin occurred and adds this to a <li> element. This newly created <li> containing the link and time is then added to the html variable. When the html variable ends, the closing </ul> tag is added.
The whole html variable is then appending via jQuery to a div with the ID of foursquare, pretty simple!
Oh, you’ll notice that the time stamp is passed through jQuery.timeago() – this is so we get a nicely formatted timestamp. You can read more about jQuery.timeago() here.
Take a look at a demo over at http://www.leonbarrett.com

12 comments
New blog posting, Display your FourSquare updates on your website – http://bit.ly/9MG2tE
This comment was originally posted on Twitter
by leonbarrett on April 6, 2010 at 6:30 pm. #
Display your FourSquare updates on your website http://ff.im/-iCMfi
This comment was originally posted on Twitter
by leonbarrett on April 6, 2010 at 9:22 pm. #
RT @leonbarrett: Display your FourSquare updates on your website http://ff.im/-iCMfi
This comment was originally posted on Twitter
by JacobDutton on April 6, 2010 at 9:23 pm. #
[...] This post was mentioned on Twitter by jacobdutton and Leon Barrett, Leon Barrett. Leon Barrett said: New blog posting, Display your FourSquare updates on your website – http://bit.ly/9MG2tE [...]
by Tweets that mention Display your FourSquare updates on your website- SizzlaBlog -- Topsy.com on April 6, 2010 at 9:55 pm. #
Display your FourSquare updates on your website http://tinyurl.com/ygbwswv
This comment was originally posted on Twitter
by TrashPixels on April 8, 2010 at 5:49 pm. #
Leon – I am trying to add my foursquare updates to my site using your instructions and comparing our source code. it seems like everything is matching up and that i should work but my updates are not appearing. is there anyway i could send you my source code for you to look at? i would really appreciate it.
by francis roman on May 9, 2010 at 5:36 pm. #
Sure, if you can send a link to the file i’ll take a look.
If you follow me on Twitter (@leonbarrett) you can send me a link there
Cheers
by Leon on May 14, 2010 at 12:28 pm. #
Leon:
I believe I have this setup correctly but appears my efforts are not yielding a functioning page. Any chance you could take a peek at the setup if I direct msg you via Twitter (@james_schaffer)
Really dig this feature – hope I can get it to work.
by James on June 28, 2010 at 4:40 am. #
There is another way of displaying your foursquare badges and mayorships on your wordpress blog.
Just go to http://myfoursquare.net and grab the My Foursquare app for Facebook. This lets you display your badges and mayorships and checkins and stuff straight on your sidebar. I just added it, and it’s pretty sweet!
by dave on August 10, 2010 at 2:57 pm. #
Hey Leon, could you help me out please? i’ve done all of the above and it doesn’t appear to be working.
by Paul on November 25, 2010 at 2:57 pm. #
Hi Paul,
What appears to be the issue?
Cheers
by Leon on November 27, 2010 at 5:11 pm. #
Hello guys,
Nice script Leon, I just got it to work so I’ll be implementing it on a personal website one of these days.
Had a couple of problems but found the solution. Maybe James and Francis can resolve their problems with my input?
Make sure, the url in your js file is correct. Mine wasn’t at first :)
Initially mine read:
url: ‘/proxy.php?……
But as my file was located in a folder called v2, I had to change it to:
url: ‘/v2/proxy.php?……
That did the trick!
by Esben on January 8, 2011 at 2:19 pm. #