Tag Archives: Coding

TwtrCtr – Tracking Twitter followers with an iPhone

twtrctr logo I’ve already mentioned this on Twitter, but so far I haven’t had a chance to write about the culmination of my first “proper” efforts to create a mashup: TwtrCtr.

For those not obsessed with Twitter or their follower numbers, there’s an application you probably haven’t heard of called TwitterCounter. The site provides tools, graphs and APIs for charting the growth of a user’s Twitter followers. It’s interesting, and if you’re slightly obsessive about figures and have a belief that such things “matter”, then you might already spend time checking it and looking at the pretty graphs. It also provides an element of “prediction” based on historical growth trends, and does cool things like allowing users to compare themselves to others and watch the graphs intersect or overlap.

twittercounter website There’s just one issue – although it looks great on the desktop, the site isn’t laid out very well for mobile browsers like Mobile Safari on the iPhone. It also uses a Flash component to display the graph, and since there’s currently no Flash on the iPhone, you get a big blank box in the middle of the screen.

The nice part is that TwitterCounter has a simple REST API which enables a developer to get the raw data about a user’s follower numbers. If you use Twitter clients like Tweetdeck, then you’ll see this in action.

Based on my previous experience of using the iWebkit framework to build an iPhone-optimised web wrapper for the data from my Current Cost meter, I thought it might be interesting to play around with using iWebkit to display the TwitterCounter stats.

iWebkit is a simple HTML framework which provides a set of CSS classes to make your web pages look like native iPhone apps. There are other frameworks out there like iUI and webapp.net, but they depend a lot more on knowledge of AJAX and some more advanced / dynamic coding, whereas iWebkit is all about simplicity – if you know your HTML basics, it is pretty straightforward. As it happens, you can extend it very easily as well – in my case, I combined it with some PHP functions which call out to TwitterCounter and echo the numbers into a table on a web page.

Although I worked with PHP a lot a few years ago, I hadn’t really done much with the language recently. The first thing I did was to create a simple piece of code to call the TwitterCounter API and get back the data for a specific user; and then I displayed it in a web page. Once I’d done that, it was pretty easy to get the whole thing wrapped into two pages of iWebkit template code, and style it all appropriately.

twtrctr mark 1

Revision one of the interface and app ran off my home server, and didn’t look fantastic. My initial thought for a name was “TwitterCounter nano”, but I changed it after realising that it didn’t fit so well as a name on the iPhone home screen :-)

In the screenshot on the left, you’ll also see that the first form I came up with was far from “iPhone native-looking”… the current version of iWebkit didn’t have form CSS classes, so I had to tweak things a little. I also found it was worth digging into the Apple Web Development Guidelines for the iPhone, which gave some hints about how to make some iPhone-specific tweaks like turning off auto-capitalisation for the text entry box (since most usernames are all in lowercase), and how to add a text hint, for example.

twtrctr mark 2 So, the second iteration of the UI looks a lot nicer. It’s also possible to hit the bookmark button in Safari and add the app as a shortcut on the iPhone home screen… (see the icon at the top of the post)… if you do that, and launch TwtrCtr from there, it will act as a full-screen iPhone app with no Safari controls, giving a much more native experience. The user can then navigate by using the controls in the header bar rather than the forward and back buttons provided by the browser.

I added an FAQ page, too, so if you want to know more about the app you can check that out directly on the site. In these days of heightened concern about Twitter security I also thought it would be a good idea to add a note on the front screen to point out that it doesn’t ask for anything more than a username, and it doesn’t log that anywhere, it just passes it on to the TwitterCounter API.

twtrctr display OK, that was a rather long explanation of the evolution of the first page! The important part is actually how the data is displayed. Once you’ve entered a valid Twitter username and hit “Get User Stats”, you get a single-page representation  of the TwitterCounter data for the given user.

The top 2 or three rows are links which will open the user’s profile page, homepage/URL (if one is set… otherwise that row doesn’t display), or display a simple graph / chart which is generated by the Google Chart API. The latter is something high on my list of enhancements, because it looks a little dull at the moment; also, I’m generating the Google Charts URL myself rather than using one of the PHP wrappers to the API, which would probably be a lot simpler.

Don’t look too closely for the rough edges… right now, it doesn’t actually make any effort deal with cases where a user doesn’t exist, or TwitterCounter or Twitter is down…. I know about those small issues :-)

In a nutshell, then – that’s all it is. A mashup which allowed me to explore a bit more iPhone-specific web development, some PHP / REST / XML coding, and a bit of Google Charts stuff as well. I have to say that the TwitterCounter folks (Boris and Arjen in particular) have been brilliant and very helpful and supportive, despite their app having an issue with the Twitter API while I was in the middle of developing this mashup on top of their API! iWebkit is a lot of fun to play with, and very simple as well – I know the developers are working hard to add new features into that framework whilst keeping it simple and aiming it at “non-techies”.

Oh, and incidentally, although the stylesheets make it look like an iPhone app, it should work perfectly well in any desktop or mobile browser – it’s plain old HTML.

I’m not making any claims about how this might develop in the future, but I’ve got a couple of ideas for tweaks that I might make. In the meantime, if you’re an iPhone (or other mobile device) Twitter user, do take a look at http://andypiper.tv/twtrctr and see how it works for you. Let me know what you think, or any ideas for additions you might find useful! Feel free to follow me on Twitter and @ your suggestions and comments to me, too.

Update: TwtrCtr is now linked directly from the TwitterCounter home page! Follow the iPhone link in the page footer! :-)

Zero

When I got back from the WebSphere Services Technical Conference in April, I posted about the level of interest in simplified development, Web Oriented Architecture and Web 2.0.

Yesterday, Project Zero emerged.

We’re talking REST, PHP, Groovy and mashups.

Come and take a look. For full details, read the FAQ and follow the blog. Then, download the code and join the community.

SLorpedo!

We just presented our team’s hack for HackDay in London…

An awesome team effort inspired and led by Paul Johnston and Nigel Crawley. A mixed reality naval game from the Supernova team.

Here’s the science part.

Camera rig The real world part(s) of the hack involved a DV cam feeding Nigel’s G4 iBook with a live feed of some pieces which represented two teams, “crabs” and “sharks” (cut from O’Reilly postcards). The camera rig – managed by Jon Hadley – was a highly technical setup involving gaffer tape and a borrowed tripod – thanks to Twitter! The iBook then used the TUIO protocol to update the coordinates of the game pieces to a web server.

The second RL part of the hack was my MacBook Pro rigged with Quicktime Broadcaster and Darwin Streaming Server, pointing at the game board. This provided a video feed that could be used within Second Life. This was technically challenging to set up due to issues connecting between the laptops on the BTOpenZone network… so someone donated us an Airport hub (again following a Twittered plea for help), and I shared my connection with Jim Purbrick who was then able to tunnel through to Second Life, as well as seeing my Quicktime stream. We experimented with a cheap USB webcam too, but the iSight just worked a lot better (positioning was “interesting” though!)

View from the blimpMeanwhile… in Second Life, the team of Jim Purbrick, Ben Hardill, Chris Mahoney and James Taylor built an amazing setup. We had a floating blimp (on Arcanum, the sim that Linden Lab had donated for the Hack Day event). The blimp contained a table which showed the live video feed of the game being played in real life. Below that, the sim was submerged. During the demo, Babbage Linden showed off the live feed, and then flew under the blimp. When he hit the floating buoy, a group of submarines were rezzed in that corresponded with the movement of the pieces in real life. Oh, and the subs were named after names found via the Yahoo! Answers API.

We didn’t quite have time to sort out the audio, but there were supposed to be some sonar noises as the subs were rezzed. Pretty easy to add, but we got moved around a couple of times prior to the demo, and had to disassemble our rig each time.

Someone managed to capture the blueprint for the hack on camera.

Oh, and as a complete aside – it is interesting to see the distribution of hardware and operating systems at the event. I’d say Macs dominate, Windows are probably second (I’ve only seen one running Vista but there may be more), and there are quite a few people running Linux too. Almost all of the demos and presentations seem to be run from Macs. W00t!

I had a spot on stage earlier in the afternoon as the “glamorous” helper for the MyBlogBunny hack, holding the Nabaztag – thanks Lance :-)

[ edit 19/06 - links and photos added, minor edits ]

[ edit 21/06 - added some more links to interesting Flickr photos ]

Technorati Tags: , , , , , , , , , ,

Automating WebSphere Message Broker deployment

Back to a topic related to my day job (!).

During the past few years I’ve come across a number of instances where customers have wanted to script the build and deployment of WebSphere Message Broker solutions. I’ve actually spoken about this a few times at conferences (an example presentation is available on my Writings page). The most common approach that customers have adopted has been to use Ant to tie in with the rest of their application build processes.

In an earlier developerWorks article, I included an example plugin node that could invoke an Ant task. There should be a build.xml file included with the sample code for this article that could help you to get started. I’ve also helped customers to write their own automated build and deployment processes.

Now, a new developerWorks article from Zhongming Chen, Ida Leung and Dave Spriet covers the use of Ant to drive the mqsicreatebar command for scripting the creation of broker archives. It’s a great article and well worth a look.

This isn’t the end of the story. Often, the overall process will also include checking out of source control, apply version tags, and deploying the BAR file. However, this article introduces the topic and should be a good starting point. You could also use the Configuration Manager Proxy API to control other broker tasks, as Matt Lucas describes in another developerWorks article.

Incidentally, if you want to know more about Ant, I personally really like the book Java Development with Ant by Erik Hatcher and Steve Loughran.

Technorati tags: , , , , ,

Oh Plazes, where art thou…

I had an email this morning announcing that the new Plazes is online, so it looks like all of the features should now be public.

There are just a few things that still bother me – I think if the team could sort these out, they might get a bit more uptake:

  1. Some of us have been kept up-to-date via email. The Plazes blog has been very quiet on the subject of the whole upgrade. I’m grateful for the alpha/beta exposure, but it seems like more awareness could have been built up around the new version by more coordinated use of blogs, email and other media.
  2. The Plazer for Windows and Mac has been re-released, but the Mac one in particular has had some problems. It would be nice if these were open sourced, or a better way of reporting issues existed than the comments in the new Mac group.
  3. The API has changed. I’ve seen inconsistent messages on the blogs or via email that certain parts of the API have been / will be removed before certain dates. The WhereAmI XML-RPC PHP endpoint has certainly been removed, and as a result my little Applescript for ecto is not currently working. The success of Web 2.0 sites is usually a lot to do with their APIs and the ease of use… right now, Plazes could be opening this up a lot more and letting the community play with the new features programmatically. The upcoming Hack Day is a case in point – participants could be making use of APIs offered by Plazes if they were made available.
  4. [added in a later edit] They seem to have stripped out some of the privacy features. Before, I could choose which of my IM accounts or email addresses to reveal publically or to contacts… this option seems to have gone. An unwelcome regression in function.

I still think Plazes is a cool site, but there’s so much more they could be doing to build their own momentum.

Technorati tags: , , , , ,