by Andrei Hetel
12. December 2009 16:17
Better think twice before starting a Facebook application using AP.NET - it's PHP world there. That could change in the future because I could see some C# example in Facebook wiki, which is a big step forward I suppose. More than this, in the glorious day when I finally manage to integrate some Facebook functionality into Ysabel, Facebook Developer Toolkit released version 3.0 (all my code is based on 2.0 - and people are complaining about backward compatibility) - that really made my day!
According with the pages that I read about ASP.NET and Facebook it's best to choose an IFRAME application type and use master pages. Not 100% if it's the best strategy, but this is what I've done.
Anyway, it took me a couple of hours to figure out how to run a FQL query, and after that to do something with the result, but it's finally working. I was surprised that only couple of lines of code are needed.
A working piece of code looks like this:
Dim fbAPI As new facebook.API
Dim query As String
Dim xmlDR As String
Dim ds As DataSet
fbAPI.ApplicationKey = "your application key"
fbAPI.Secret = "your secret key"
query = "select uid, name from user where uid in (select uid2 from friend where uid1=" & your_Facebook ID & ")"
xmlDR = fbAPI.fql.query(query)
ds = New DataSet()
ds.ReadXml(New StringReader(xmlDR), XmlReadMode.InferSchema)
Dataset returned contains 2 datatables, in the second datatable is the data you have requested (complete list of your friends according to the above query).
Simple isn't it? Happy coding.