Saturday, 9 August 2008

Popfly Mashup and Custom Block

As part of the work experience that I have been doing with the Popfly team I have been creating a number of mashups that would be able to be demoed as part of presentations and then be used with hands on labs so that the audience could go and create these mashup's themselves.

One of the mashups that has been created for the hands on labs is the creation of a twitter friend comparer, this will compaire the number of friends one user has against the other and give the results on a bar chart. The user who deploys the app will hard code their own user name in the app and then embed it into a website or facebook. Anyone visiting that page will then be able to input their own twitter screen name to see has the most friends.

(a number of errors may still occour with the mashup due to problem with the twitter API)

Creating this mashup posed a number of problems, one of which was that currently none of the social network API's/blocks support getting the number of friends a user has. Instead the API returns an array of objects that represent a friend. The number of friends can then be found by the number of objects in this array.

To do this I created a custom block that checks the ammount of entrys in the array from the input blocks. This can work for any number of blocks of any type, so if a Facebook block returns 147 friends the count block will output an integer with the value of 147.

This allows the above mashup to get the number of friends each of the users have and then display this integer to the bar graph block as data.

The created mashup can be found here and the "count" block can be found under the tool sub folder in Popfly.

No comments: