Hello All!
Lately, I have been spending some time working with Silverlight in the context of the Facebook api. I've been amazed at the amount of data the api gives you access to. With the incredible growth facebook is experiencing (check this out: http://www.insidefacebook.com/2008/07/29/tracking-facebooks-2008-international-growth-by-country/), there are many opportunities blooming for developers that can use the information to improve / innovate with their own products. If you are a marketing / advertising business and you are not leveraging this information in one way or another, then I would say you are missing out!
In a past post (Facebook Connect Post) I showed everyone how to set up an application in Facebook and how to use Facebook Connect with Silverlight to create a simple login screen. That was a trivial proof of concept to show how one might implement such things on their Silverlight App. This post will build on the previous post, and introduce a very alpha version of a Silverlight client side api I have been working on for a little bit.
There has been many articles written on how to hook up the a Silverlight app to Facebook, but it's always used the web server as a bridge to get the data back from the Facebook api. Pete Brown did a wonderful job illustrating this in this blog post using the Facebook Developer Toolkit via Clarity Consulting. I think using your web server as the bridge to the Facebook api is slightly wasteful. As a result of that conclusion I decided to port the api to the client side. I felt it would be nice to offload much of the weight of the web requests onto the Facebook servers rather than my poorly funded web servers :). I also think this will allow for an architecture that will scale much better than the web server bridge.
<disclaimer>
If / When you look at the code, please understand this is just an api and a demo. There is little or no abstraction. There is no caching / real object model. I built this as a proof of concept and will advance it in a bit. Heck, I don't even know if this is going to garner any attention...
</disclaimer>
When I was building the api, I came to the conclusion, very early down the path, that web request completed event handlers and custom delegates are the devil, Bobby Boucher. I always want to write the call to the method, then have to go back and wire up the delegate for the call back. It bugs the hell out of me that I can't just pass an action into the method call. With that thought in my head, I made the api use generic actions passed into the api requests rather than callbacks. I'm not sure how this will go over, but I have found it a little easier to read. I do love lambdas, so I might be a bit biased in that choice.
One important thing to note about the Facebook api: It might not give you back what the xsd promises. I think I have fixed all of the places where this issue cropped up.
After you download the code, there are few things you will need to do to run the demo app. You will need to follow my original post to create an application in Facebook and get facebook connect set up for the demo. Basically, after you get your application key and secret key, you just need to plug them into a couple spots (ApplicationContext.cs, Default.aspx, and your secret key in value for app setting "secret" in the web.config). You may also need to update your service references to point to the fake host name you set up in your hosts file (from the previous post). That should get you to the point where you have the demo running.
Comments are welcomed. Bugs are welcomed. Calling me a complete butthead is welcomed. I will get back to you if you are kind enough to ask about something.
Finally, I have to give a couple shout outs. Thank you very much to the Madison, WI .NET Users group for letting me use your members as a sounding board. Lance Larsen and Travis Feirtag were kind enough to give me some time at the latest meeting. Thank you very much guys. Check them out at http://www.maddotnet.com/. Last but not least, I want to give a big high five to the guys over at http://mightymeaty.members.winisp.net/blacklight.silverlight/. They do some really cool stuff with Silverlight controls. I'm continually impressed with the quality and UX this group creates. If you look at the controls in the demo, you will notice i'm utilizing some of their controls and styles. I would recommend testing out their stuff if you get a chance.
Twitter: David Justice
Code
