The ball

Facebook, C# and ASP.NET MVC – Code samples for friends list, activities list and wall posts

August 11, 2010 by onishimura · 5 Comments
Filed under: .NET, ASP.NET MVC, Facebook 

A few weeks back I wrote about the official C# SDK from Facebook and provided some sample code demonstrating how to use it to get some basic information about the logged in user. Admittedly the initial sample asp.net mvc code was fairly simple in order for it to be straight forward and easy to understand. I’ve decided to expand a bit on the sample in order to demonstrate how to use the Open graph API to perform a few more interesting calls, notably:

  • Post to a user’s wall
  • Retrieve a list of the user’s friends
  • Retrieve a list of the user’s activities

The original sample code demonstrated how to authenticate a user and make calls using both the official C# sdk and a home grown solution. I’ve kept that approach but have organized and refactored the samples a bit better to make it hopefully more clear. The new version of the sample code allows you to login/out to facebook only on the home page. Once logged in you can go to the ‘Official’ and ‘Custom’ tabs to view your friends, activities or to post a message to your wall. While the functionality is the same between the two tabs, the code behind them is different. I assume most people would use the official SDK but I provided an alternative just as a point of interest. OK, I was bored really, and just wanted to see how it could be done differently.

Read more

Official Facebook C# SDK Released

July 17, 2010 by onishimura · 6 Comments
Filed under: ASP.NET MVC, Facebook 

Looks like a brand new SDK to play with for facebook. While they have other sdks for python, php, javascript, etc, this is their first official C# SDK. Previously the primary SDK that was available was the Facebook Developers Toolkit, which hasn’t been updated in some time (and hasn’t been updated to support the open graph api as far as I can tell).

You can grab the code from github at http://github.com/facebook/csharp-sdk.

Read more