This project is read-only.

Quick Start

This wiki contains a limited amount of information intended to be the minimal amount of effort to get started working on a project using FBGraph.NET.

Creating your Facebook Application

Note: If you've already created and configured the settings for your Facebook Application, or you already know how, you may skip to Adding FBGraph.NET.
  1. In the Facebook Developer application, click Set Up New Application in the upper right.
  2. Pick a name, review and agree to the Facebook Terms, and click Create Application.

Web Applications Only (Including Silverlight)
  1. Click the Canvas tab on the left
  2. Pick a canvas url.
  3. If you are going to be using the built-in web server (Cassini) for development:
    1. In Visual Studio, create your web application or web site project. , hit, select your project in the Solution Explorer and press CTRL+ENTER to open the properties. On the Web tab, under Servers, select Specific Port and copy the port number.
    2. Back on the Facebook Application configuration page, enter the url http://localhost:{portnumber} into the Canvas Callback Url field, substituting the port number you copied from Visual Studio for {portnumber}.
  4. If you are not using the Cassini for development:
    1. Enter the url you will be using for your development server in the Canvas Callback Url field.
  5. On the Connect tab, enter the same url in the Connect URL field
  6. If your url contains a subdomain, enter the base domain into the Base Domain field.
    1. For example, if your url is, enter into Base Domain.
    2. If you are using an IP address as your url, do not enter anything.
  7. Click Save Changes at the bottom.

Desktop Applications Only
  1. On the Advanced tab, select Desktop in the Application Type field.
  2. Click Save Changes at the bottom.

Adding FBGraph.NET

Add the following library references to your project:
  • FBGraph.Core.dll
  • FBGraph.Api.dll
  • Newtonsoft.Json
All ASP.NET Web Sites and Applications:
  • FBGraph.Web.dll
ASP.NET MVC Applications:
  • FBGraph.Mvc.dll

Configuring FBGraph.NET

  1. In the Facebook Developer application, select your application from the list on the left.
  2. Locate the Application Secret and Application ID values.
  3. In your application's web.config (for web applications) or app.config (for desktop applications), add the following <appSettings> entries:
<add key="ClientID" value="{Application ID}" />
<add key="ClientSecret" value="{Application Secret}" />
Note: Throughout the FBGraph.NET project and its documentation, "Application ID" and "Application Secret" are referred to as "Client ID" and "Client Secret", respectively, because Facebook's Graph API Documentation uses the latter terminology.

Web Applications
If you plan on having FBGraph.NET handle authentication and extended permissions (recommended!), add the following <appSettings> entry:
<add key="AuthUrl" value="~/Auth" />


The FBGraphContext class encapsulates all functionality in FBGraph.NET, and acts as a starting point for any call you need to make, not unlike HttpContext for web applications. FBGraphContext has a parameterless constructor, so all that you need to do to get an instance is:
var context = new FBGraphContext();

Retrieving Information

  • Each type of retrievable data, or Model, has its own Controller property off of the FBGraphContext. For example, Users, Events and Pages.
  • Some controllers, such as Users represent individual objects. Others represent connections of other objects, such as Comments. Some controllers provide access to both. For example, Events may provide access to a specific event, or a User or Page's events connection.
  • Get() and its overloads will retrieve a specific object from the Graph API. For example, Users.Get() will retrieve information about the currently authenticated user.
  • GetFor() and its overloads retrieve a list of data from an object's connection. For example, Events.GetFor() will retrieve a list of events associated with the currently authenticated user.
  • Both of the above methods have overloads for accept a target object ID, as well as overloads for filtering by date and paging.
var context = new FBGraphContext();
var myEvents = context.Events.GetFor();

Writing Information

  • Each of the controllers has a Create() or similarly appropriately named method for creating the specified object.
  • All writing methods return the ID of the newly created object
The following snippet creates a new event for the current user starting in one hour and lasting for two hours:
var context = new FBGraphContext();
var start = DateTime.Now.AddHours(1);
var end = start.AddHours(2);
var myEventId = context.Events.Create(null, "My Event", start, end);


Last edited May 7, 2010 at 5:04 AM by DanielSchaffer, version 14


No comments yet.