Coder Social home page Coder Social logo

facebook-csharp-sdk's Introduction

Facebook C# SDK

NOTE: THIS SDK IS DEPRECATED. WE ARE KNOW LONGER SUPPORTING IT AND IT WILL BE MADE PRIVATE SOON.

This SDK provides a light wrapper around the Facebook Graph API.

Getting Started

The easiest way to get started is to have Visual Studio. You can get a free copy of Visual C# 2010 Express Edition from Microsoft.

The instructions that follow will assume that are you using this version. The steps are very similar for other versions.

Once you have installed it and downloaded the source of the SDK, you will need to build the library. Open facebook/FacebookAPI.csproj. It may ask you to create a solution, in which case you can just use the default name. Right click on FacebookAPI in the Solution Explorer and choose Build. This shouldn't take very long. The SDK is ready to use. You can either build on top of this project, or use the DLL directly in another project.

There is a sample app included, which shows an example of the latter. Open examples/FacebookSampleApp.csproj. Again, it may ask you to create a solution. Go to the Solution Explorer and right click on References and choose Add a Reference. Navigate to the DLL you built and select it. Now build the project, and run it. You should see the string Mark Zuckerberg printed out, if everything worked.

Access Token

Most data accessible via the Graph API required an access token. This SDK does not include a method of getting a token from a user, as the best method will depend on what type of application is using it. A desktop application might show a popup browser window that loads the Facebook site, for example. You can read more about obtaining an access token in the authentication guide.

Calling the Graph API

First you instantiate an API object (passing in the token):

Facebook.FacebookAPI api = new Facebook.FacebookAPI(token);

If you pass in null then you will only be able to access public data. Then you make calls like:

JSONObject result = api.Get("/userid");

The JSONObject class provides a wrapper around JSON that allows for automatic type conversion. In particular, it can treat JSON as a Dictionary, Array, String, or Integer. So to get the name of the userid as a string you would do:

string name = result.Dictionary["name"].String;

The SDK also supports POST and DELETE requests, for writing data. For example to delete a comment once you have gotten its id you could do:

api.Delete("/comment_id");

To write a post on a user's wall you could do:

Dictionary<string, string> postArgs = new Dictionary<string, string>();
postArgs["message"] = "Hello, world!";
api.Post("/userid/feed", postArgs);

More information on the API itself can be found in the developer documentation.

Errors

Any errors in making Graph API calls cause a FacebookAPIException to be thrown.

facebook-csharp-sdk's People

Contributors

agoder avatar daaku avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

lahadji

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.