The Facebook utility allows you to connect to facebook, update your status, download your friends list, or publish a message on a friend’s wall.
The first thing you need to do before to use this control is to register your app with Facebook.
Go to this page : http://www.facebook.com/developers/, and click on the button “+ Set up new app”.
When you have filled several information about your app, you will get your application Id and secret token
You can now use the BPC Facebook control.
The first thing to do is to add the facebook control to your page, and to set the app Id the the app secret :
<Phone:FacebookLoginControl x:Name="facebook" AppID="154224837975096" AppSecret="1c24f3ba7537d68efb218ee81bab232f" />
This control is collapsed by default, and will be automatically show a web browser and/or a progress bar when needed (on publication or on the friend list download).
You can now use this control in your code behind to connect to facebook :
private void Connect_Click(object sender, RoutedEventArgs e)
{
if (facebook.IsConnected)
MessageBox.Show("You are already connected");
else
{
facebook.ConnectionCompleted += new EventHandler(facebook_ConnectionCompleted);
facebook.Connect();
}
}
To download the friends list, you can call the method GetFriendsListAsync(). You will receive the list in the GetFriendsCompleted event as an array of FacebookUser.
private void loadFriends_Click(object sender, RoutedEventArgs e)
{
facebook.GetFriendsCompleted += new EventHandler<Bewise.Phone.GetFriendsEventArgs>(facebook_GetFriendsCompleted);
facebook.GetFriendsListAsync();
}
void facebook_GetFriendsCompleted(object sender, Bewise.Phone.GetFriendsEventArgs e)
{
friendList.ItemsSource = e.Friends;
}
You can use one of these methods to post a message :
public void PostToMyWall(string message)
public void PostToMyWall(string caption, string description, string link, string message, string name, string pictureLink)
public void PostToFriendWall(String userId, String message)
public void PostToFriendWall(String userId, string caption, string description, string link, string message, string name, string pictureLink)