|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
Introduction
In this first article, I will provide an overview of how to set up your Setting up FacebookVisit the developer website.
Keep the API Key & Secret provided for use later. Here is a discussion about whether it is legal to disclose the secret key of your application. Creating a simple UIDownload the Create a WPF Application and add <StackPanel>
<Image x:Name="ProfilePicture"Stretch="None"HorizontalAlignment=
"Left"VerticalAlignment="Top"/>
<ListBox x:Name="FriendsListBox"/>
</StackPanel>
Add the following References to your project:
Also add the following namespaces: using Facebook.Components; //FacebookService
using Facebook.Exceptions;
using Facebook.Entity; //User
using System.Windows.Media.Imaging; //BitmapImage
using System.Collections.ObjectModel; //Collection
Next, we have to create an instance of the FacebookService service;
Now, we also need to setup the service with the API Key & Secret recorded earlier. I currently do this in the constructor of my Window. service = new FacebookService();
service.IsDesktopApplication = true;
service.ApplicationKey = "1969299cd5b87513af9633715e0a63e9";
service.Secret = "5b3ff1b88c41eb117014f403e5cb9952";
Now we are ready to start getting information from User me = service.GetUserInfo();
if (me != null)
ProfilePicture.Source = new BitmapImage(me.PictureSmallUrl);
This basically downloads the small profile picture from the specified URL. This is a good time to save and test your project. Once you have compiled and Run this application, the following logon screen gets displayed:
I have also noticed that this currently doesn't work if you are behind an HTTP proxy server. I get a "The underlying connection was closed" exception. Future releases of Fill in your user name and password and now click on login. You should hopefully now see a Window with your profile picture displayed! The next step is to populate the Collection<User> friends = service.GetFriends();
Update the friend's <ListBox x:Name="FriendsListBox" ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Path=PictureSmallUrl}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
The final step is to point the FriendsListBox.ItemsSource = friends;
ConclusionAs you can see, to setup and create a simple
With very little effort and quick beautifying touches, the final application looks like this! (I borrowed Sacha Barber's Glass Button effect for the Please comment on how I can improve my articles (since this is only my second) and also rate this article (even if you thought it was utterly useless!) LinksHistory
|
||||||||||||||||||||||