Welcome to MSDN Blogs Sign in | Join | Help

.net ready !!!

        Maxime Lamure
          MCS France
Create your own desktop Facebook application in C#

In France, FaceBook is coming since a few months … and it makes a lot of noise. What is cool with this social network, it’s that we can develop customs applications.

I decided to explain steps to create a windows form which get facebook information.

First of all you have to create a FaceBook application in facebook:

Subscribe to Facebook

  1. Add the Facebook developer application (http://www.facebook.com/developers/)
  2. Create new application
    • Facebook provide you an API Key and a secret
  3. Edit your application to fill the Canvas Page URL and the CallBack Url
  4. Save your settings

Now that you have the API Key and a secret, you can develop your application:

  1. Install the Facebook developer toolkit (http://www.codeplex.com/FacebookToolkit)
  2. In Visual studio, check in the toolbar that you have facebook items (FaceBookService with facebook.dll, FriendMap,FriendList with Facebook.Controls.dll)
  3. Create a Windows Application
  4. Drag and drop FriendMap, FriendList and buttonControl on your windows form
  5. Add the following Code:

 

public partial class Form1 : Form
{

public Facebook.Components.FacebookService _fbService;

public Form1()
{
       InitializeComponent();
       _fbService = new Facebook.Components.FacebookService();
       _fbService.ApplicationKey = "ApplicationKey";
       _fbService.Secret = "Secret";
       _fbService.IsDesktopApplication = true;
}

private void button1_Click(object sender, EventArgs e)
{
      Collection<User> users = _fbService.GetFriends();
      friendMap1.Friends = users;
     friendList1.Friends = users;
}

}

 

F5 and enjoy :-)

Posted: Friday, December 14, 2007 12:44 PM by Maxime LAMURE

Comments

farahota said:

Hello, what is the User object in Collection<User>?

I get a compile error as it is not referenced or defined anywhere.

Thanks in advance,

farahota

# May 11, 2008 2:34 AM

Maxime said:

Hello,

You can find the User object in the Facebook.Entity namespace:  

Collection<Facebook.Entity.User> f = _fbService.GetFriends();

# May 11, 2008 4:19 AM

anoush said:

just want to ask what will be the callback url

# June 16, 2008 9:04 AM

Derycke Nicolas said:

I got an error on the line:

Collection<User> users = _fbService.GetFriends();

Error:

ArgumentException was unhandled by user code

the request value LiberalAndCentreUnion is not found.

I'm running this localhost

Do somebody know what's the problem?

# October 23, 2008 4:43 PM

Enthusiast said:

It says "The type or namespace name 'Collection' could not be found (are you missing a using directive or an assembly reference?)" Please help me.

Thanks

# May 22, 2009 2:33 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker