Skip to content


Stack Overflow WordPress Widget

If you haven’t already, you should really check out Stack Overflow; it’s a community driven programming questions/answers site where people earn reputation and badges for contributing.

I wanted to put an XBox Live style "gamertag" on my blog with a link to my Stack Overflow profile and my current "reputation". I couldn’t find anything out there so I thought I’d dig up some Widget sample code and steal adapt it to display what I wanted.

There doesn’t seem to be any API for getting the information I wanted, so it uses a basic screen scrape, which may well stop working if they tweak the pages and may well not work for everyone’s profile page, but it works for mine and that’s all I care about ;-) Seriously though, if anyone else wants to use it and has problems, feel free to drop me a line and I’ll take a look at it. I’m no PHP expert either, so if anyone wants to tell me if my code sucks horribly, feel free :-D

You should be able to see the widget over on the right, and you can grab the widget itself below. Once it’s installed you need to configure it to give it your user number (26507 in my case) and your email address (so it can pull out your Gravatar). The email address isn’t used for anything other than hashing for the Gravatar, but you can read the source if you don’t believe me :-)

Update: I’ve made a few changes in response to a few comments, and also removed the little place holder and badges in there.  It takes into account badges that have been awarded multiple times, so it *should* be the same as your SO page :-)

Update2: Thanks to Ólafur Waage for providing an update to add a clear div after the widget and to run the name through htmlentities to handle names with “funky characters” :-)

Update3: Version 2.0.0 is now available on the Wordpress plugin page. It has a simple cachine system and also now pulls its data from the Stack Overflow JSON feed, rather than using screen scraping. More info in the new post: Updated: Stack Overflow Wordpress Widget.

New screenshot and download below:

Stack Overflow Widget

sowidget.zip

Share:
  • Twitter
  • DotNetKicks
  • DotNetShoutout
  • Google Bookmarks
  • Digg
  • del.icio.us
  • Live
  • Technorati
  • StumbleUpon
  • E-mail this story to a friend!
  • Netvibes
  • Ping.fm
  • Print this article!
  • Reddit

Technorati Tags: , ,

Posted in Misc.

Tagged with , , .


9 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. tinkertim says

    I’m amazed that SO does not provide some kind of API for this. It would be really need to widget-ize your user summary (such as you have) as well as being able to pull in the last few questions that you have asked.

    This would enable you to push the questions to your blog, which hopefully gets more people involved with SO.

  2. Ólafur Waage says

    I have modified your code, pray i do not modify it further. :D

    I had some issues with floats below the widget so i added a clear div tag, i also had issues with my name, since it has funky characters, so i added an htmlentities to decode it.

    Here’s the code if you want to update it.
    http://cznp.com/sowpw.phps

    Thanks :D

    • srobbins says

      Excellent, thanks, I’ll update the code on here and on WordPress when I get a minute. I did wonder how it would handle all the wierd and wonderful WordPress setups, but I didn’t even consider wierd and wonderful names :-)

  3. Paul Tomblin says

    The SO team is complaining that I’m hitting my user page too often from the colo box that hosts my blog, and the only reason I can see is the SO widget. Is there any way we can cache the information or somehow hit it less often?

    • srobbins says

      I’ve seen a mail from SO this morning – I’ll pop you both a reply via email.

Continuing the Discussion

  1. WordPress Plugin Releases for 01/16 | Weblog Tools Collection linked to this post on 16/01/2009

    [...] Stack Overflow “GamerTag” Style Reputation Widget [...]

  2. WordPress Plugin Releases for 01/16 | Web 3.0 Technology.com linked to this post on 16/01/2009

    [...] Stack Overflow “GamerTag” Style Reputation Widget [...]

  3. WordPress Plugin Releases for 01/16 | BlogBroker24-7 linked to this post on 16/01/2009

    [...] Stack Overflow “GamerTag” Style Reputation Widget [...]

  4. New WordPress Plugin Releases After 01/10 | Web About Money linked to this post on 18/01/2009

    [...] Stack Overflow “GamerTag” Style Reputation Widget :XBox Live “GameTag” style widget for displaying your Stack Overflow rep. [...]



Some HTML is OK

or, reply to this post via trackback.