/labs

This is a blog by the staff at the web agency Earth People in Stockholm Sweden. Check out our work and get in contact with us here.

Getting stats from the Facebook Like button your way

2010-09-05 21:28:48

So you’ve implemented the Facebook Like button, and you’d like to know – programmatically – what your users Like on your site. This is a bit of a pain, since there’s nothing in the Facebook Open Graph for this. There’s some stuff in the insights api, but it’s not really usable if you’d like to do anything fun with your data.

I’ve written a PHP class which you can download and use anyway you see fit. It’s kind of simple, but will get the job done. You probably want to add some caching to it, since the old REST-api we’re querying isn’t very responsive.

Use it like this:

# create new instance of like class
$FbLikes = new FbLikes();

# add all the urls you want to measure
$FbLikes->addUrl('http://earthpeople.se/labs/');
$FbLikes->addUrl('http://wplove.se/kom-pa-wpbar/');
$FbLikes->addUrl('http://debaser.se/');

# set the sort order, either 'likes' or 'untouched'
$FbLikes->order_by = 'likes';

# get all the fb like data
$likes = $FbLikes->getLikes();

# echo the results
if($likes){
  foreach($likes as $row){
    echo $row->normalized_url . ': ' . $row->like_count . " facebook likes\n";
  }
}

Enjoy – or fork!

/ peder fjällström

webhook thingie

2010-03-23 21:17:17

so you want to be able to ping your local computer when something happens on the internet? not a problem, thanks to xmpphp. the flow would be:
your code -> xmpphp -> googletalk -> adium -> growl. neat huh?

some ideas where this may come in handy:
- when a cron script finishes on a server,
- whenever a comment is held for moderation on your blog,
- on successful svn commit or deploy from springloops (or beanstalk?) which uses webhooks. this is how we use it…

to get this working, download the xmpphp files from google code and tweak the example files according to your needs.

this will not work on all webhosts though, and to be honest the only shared hosting i got this working on is dreamhost. any vps will probably do, as long as the firewall is configured correctly (or turned off…).

(UPDATE: through the wonders of twitter i heard about this python project, using google app engine. fyi.)

/ peder fjällström

music hack day

2010-02-04 07:48:36

so, we (@fjallstrom + @mjelle) went to #musichackday stockholm and hacked stuff.
the idea came up during lunch on friday, and by sunday at 14.01 we had
a working(well…) site ready.
http://tunemyfeed.com

read more about this hack and what others did at:
http://stockholm.musichackday.org/index.php?page=Tune+My+Feed

technologies we used:
php
codeigniter
facebook connect api
google language detector api
google translate api
yql / yahoo term extractor api
last.fm api
spotify metadata api
jquery

known bugs:
the fancy ajax stuff leaks memory like your mother. wontfix – it’s a hack.

made some decent contacts and had massive fun. now – wash up and sleep.
huge thanks to henrik, mattias and dave (and the sponsors) for putting
the hack day together.

/ peder fjällström

battleships – with real ships!

2009-11-27 10:54:42

someone on twitter passed on a link to a site where one could track 11000 ships, live on a map. excited about the vast chunk of scrapable data i started chatting to my buddy tnobs about this, and we came up with a fun hack… but who’s got time to hack stuff for fun? well, i got way too excited and started right away. at the end of play the same day – this battleship inspired game was live.

Skärmavbild 2009-11-29 kl. 12.04.56

the idea is pretty simple – select weapon and click anywhere on the world map. if you’re lucky you’ll hit a ship. much like the old battleship board game, with two exceptions. it’s based on real data – the ships are real ships, on the seven seas of the world. and this “game” lack all the drama of a real game… try it here!

well, i can’t see that i’ll be hacking away any further on this project, it was a fun proof of concept and i learnt a little. if you get any great ideas on how to hack this into something usable, email me.

/ peder fjällström