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
- Add the Facebook developer application (https://www.facebook.com/developers/)
- Create new application
- Facebook provide you an API Key and a secret
- Edit your application to fill the Canvas Page URL and the CallBack Url
- Save your settings
Now that you have the API Key and a secret, you can develop your application:
- Install the Facebook developer toolkit (https://www.codeplex.com/FacebookToolkit)
- In Visual studio, check in the toolbar that you have facebook items (FaceBookService with facebook.dll, FriendMap,FriendList with Facebook.Controls.dll)
- Create a Windows Application
- Drag and drop FriendMap, FriendList and buttonControl on your windows form
- 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 :-)
Comments
Anonymous
December 14, 2007
PingBack from http://msdnrss.thecoderblogs.com/2007/12/14/Anonymous
May 10, 2008
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, farahotaAnonymous
May 10, 2008
Hello, You can find the User object in the Facebook.Entity namespace: Collection<Facebook.Entity.User> f = _fbService.GetFriends();Anonymous
June 16, 2008
just want to ask what will be the callback urlAnonymous
October 23, 2008
The comment has been removedAnonymous
May 22, 2009
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. ThanksAnonymous
January 12, 2010
could you please change the code with respect to the code changed with version 3.0 of facebook development kit it would be really helpful i am not much of a c# user and new to it your code is incompatible with the new vesrions please help Thanks in advanceAnonymous
July 27, 2010
Can anybody help me to find out how to retrieve albums of face book in c# windows application.Anonymous
August 10, 2010
FacebookService class is not having GetFriends() method it is displaying an error.Anonymous
September 14, 2010
How can we login in facebook using desktop application. Where we have to provide our facebook username and password. How it will recognise the user. I m using facebookService1.GetExtendedPermission(facebook.Types.Enums.Extended_Permissions.status_update); but it is giving erro dat GetExtendedPermission and facebook does not exists.Anonymous
October 05, 2010
What will be the callback url? Thank YouAnonymous
December 01, 2010
I don't really get the url part. Kindly help outAnonymous
February 06, 2011
Collection<User> users = _fbService.GetFriends(); Error:namespace doesnot findAnonymous
September 13, 2011
I want to information about c# desktop application you can send as email by following account santoshgade26@yahoo.inAnonymous
February 25, 2014
The comment has been removed