Current Article
Industry Buzz
Social Networking
Featured Articles
Browse Content >
Back to Home

How to Use the Facebook Developer Toolkit 2.0

Bill Konrad
The Facebook Developer Toolkit project has just released version 2.0 of their ASP.NET API into the wild, so let's go over the basics. In this article, we focus on creating an absolutely bare bones FBML application that leverages the API. Enjoy!

Introduction

This snippet is just the start of a series of articles written to explain the most commonly used features of the Facebook Developer Toolkit API. I promised Brian Goldfarb that I would help support the community, and I intend to follow through. Thanks to Microsoft for supporting social networking development using the .NET framework!

With that said, let's get started.

Download the Facebook Developer Toolkit. Here is a link to the CodePlex Project.

Once you have the binaries on your local disk, we need to set up our Facebook application.

Setting up a Facebook Application

The process is actually quite simple. First we need to install the "Developer" application, provided by Facebook.

Here is a link - Facebook Developer Application

Launch the Developer application and click "Set Up New Application" in the top right hand corner.

You will see the following screen. I have filled in the necessary fields, but here is a quick rundown.

1. Application Name - You must pick one.
2. Callback URL - This is the address of your hosted facebook application.
3. Canvas Page URL - Give your application a nice, memorable address on Facebook.


Note: Just below "Canvas Page URL" are two radio buttons. Select "Use FBML".



After you click "Submit" you will be taken to the following screen which will show you details about your newly created application.



Take note of two key fields we will reuse later: API Key, Secret.

Writing our Bare Bones Application

I want to quickly reiterate that this is simply the absolute least amount of code you could possibly write and still have a functional application. In my opinion this is the best way to get started because it emphasizes what you must keep in place while allowing you to build from a simple code base.

Our ASP.NET Solution has a mere 8 files including binaries. The screenshot below demos our Solution Explorer.

Adding the Necessary Binaries

You can see from the screenshot that our Bin folder contains 5 files.


All of these can be dragged and dropped from the included binaries in the Toolkit download. They are, just to make this overly clear: facebook.dll, facebook.web.dll, facebook.web.xml, facebook.xml, and Microsoft.Xml.Schema.Linq.dll.

Setting up Web.Config

We need to configure a few settings for the Toolkit to understand who we are. Here is the full XML passage from web.config.


        
        
        

Go back to the Developer application in Facebook and extract the correct APIKey, Secret, and Callback URL values from your new application's profile. You can reference the screenshot we already reviewed to help find this page.

Remove HTML and BODY Tags

This may seem like a bizarre step in the process, but let me briefly explain why this step is necessary. First let's look at the code in Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<form id="form1" runat="server">
Hello, <%= API.users.getInfo().name %>
</form>


You can see that we have only kept the code between the two FORM tags. So why do we need to get rid of HTML and BODY? I will go into further detail in a later article, but essentially, any code that is written in an FBML based application is interpreted and injected directly into the Facebook platform. So when your users view your application, if you were to keep these tags and then view the generated HTML source, you would have an HTML tag inside of Facebook's HTML tag. It's not hard to see why this would be a problem!

More of that later, but for now let's keep moving.

Referencing the Toolkit

Open Default.aspx.cs. The code is so short that I have pasted the full text for analysis.

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using facebook;
using facebook.web;

public partial class _Default : facebook.web.CanvasFBMLBasePage
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        base.RequireLogin = true;
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }
}


There are three points of interest here.

1. We reference facebook and facebook.web in our "usings" section. This gives us access to the Toolkit binaries.

2. We derive class _Default from facebook.web.CanvasFBMLBasePage. This derivation hides most of the dirty work in actually authenticating with Facebook!

3. We set the flag base.RequireLogin = true; This line forces users to be logged in to the Facebook platform before viewing your application. By enforcing this, we can be sure that we will have access to a user's data.

Requesting User Information from the API

In this final step we bring it all together. Let's see how we can now access our user's information and beging to leverage the "social graph" so to speak.

Refer back to Default.aspx. You will see the following code.

Hello, <%= API.users.getInfo().name %>


We access the user's basic profile information and select the name field. When we run the code, it will print something like the following.

Hello, Bill Konrad

Hosting the Application

Host your ASP.NET solution at the Callback URL you specified in your application's profile, and load it up for the first time by visiting your http://apps.facebook.com/yourapplication/ page.

That's it! Take the basic foundation delivered here, and run with it. The possibilities are limitless and this is only the tip of the iceberg. If you enjoyed the article, please link to it and share with your friends.

Subscribe to our RSS feed for many more articles to come and download the full code below.

Download Full Sample Code

Share Article

User Comments

Gravatar
Tai Elon
11/7/2008
great article, right to the point, just what everyone needed
Gravatar
Mark Henderson
11/11/2008
I can't wait to give this ago... Why hasn't the Facebook.net framework majig been given more press!

This is beyond my wildest dreams for what I want to do..


Can't wait for the follow up!

Cheers,
M
Gravatar
Bill Konrad
11/11/2008
Mark,

Thanks for the great feedback. Is there any topic in particular that you think often stumps people? We want to address the really common problems and build up a strong base for the community.

Let us know!
Gravatar
Ivan
11/12/2008
Thanks for the update. It would be great to have a guide on updating from the previous Toolkit (1.x) to this version (what's new, old, gotchas, etc.)

Thanks.

Ivan
Gravatar
Anthony Morgan
11/25/2008
This was nice and simple, the one stumbling block I had was not putting a slash after my url, e.g.
http://www.mysite.com/subdirectory1 &lt;- should be a slash here. You get a generic message

Received HTTP error code 405 while loading ...

however, you can see whats happening by going directly to the website, view source to get the facebook url

&lt;fb:redirect url=&quot;http://www.facebook.com/login.php?api_key=...&amp;v=1.0&amp;next=Default.aspx&quot;/&gt;

and then trying to go directly to that url, which in my case came up with the message

Requested URL: /subdirectory1Default.aspx not found
Gravatar
Swoop
12/3/2008
Great little tutorial. Are there going to be more tutorials about the same subject ?
Gravatar
Lee
12/12/2008
What might be helpful at this point is to explain how the .net framework works with something added to a user's profile. For example, following the above example is extremely easy and very useful, but it only gets you so far. I realise it may be more a question for Facebook forums, but once you do the above you still do not have an application that will live on a profile page. For this, as far as I can figure out, one must use setFBML and include a button to add to profile. Your API includes the method to call setFBML - it would be useful to include some detail about this to &quot;close the loop&quot;, as it were.

Just my thoughts. Excellent API by the way - well done and many thanks
Gravatar
Jorge
12/15/2008
Me sirvio bastante el articulo. Por fin encontre lo que necesitaba para disipar dudas.
Gravatar
platha
12/17/2008
I am unable to deploy the application i have created... I think its the problem with call back url.. what is the use of call back url? how to declare it? how to add some more features to my application?
Gravatar
Anonymous
12/17/2008
Too bad that .net facebook framework is built by Clarity. I wouldn't touch any code that comes out of that consulting group. It's usually an overly complex pile without any form of standards and typical a hidious data layer.
Gravatar
Jorge
12/17/2008
I have a problem, when I use FriendList and PhotoAlbum it was showing a lot of errors as &quot;URLExceptionInvalid scheme for url &quot;, someone know what do I need to do?, how can i fix it?
Gravatar
Robin Bonin
12/17/2008
I tried this example out, but I am getting an exception when loading my aspx page directly. &quot;Invalid API key&quot;

When loading it from the canvas page, I get

Errors while loading page from application

Received HTTP error code 500 while loading (my url here)

There are still a few kinks Facebook and the makers of What's in my (app name) are trying to iron out. We appreciate your patience as we try to fix these issues. Your problem has been logged - if it persists, please come back in a few days. Thanks!

Did I miss something?
Gravatar
Robin Bonin
12/17/2008
My issue was I had AutoEventWireup=&quot;false&quot; in my aspx page.
Gravatar
mohamad
12/21/2008
i can not implaymet it
Gravatar
Joel
12/22/2008
It runs but shows blank... and then when I &quot;View Source&quot; it shows:

&lt;fb:redirect url=&quot;http://www.facebook.com/login.php?api_key=4bdc9eba82ae956fb2d894a76409531d&amp;v=1.0&amp;next=Default.aspx&quot;/&gt;

so I copy the redirect url and then it works! What gives? is the fb:redirect bugged as its not redirecting?

Hmmmmm... but I guess its enough to test new apps...
Gravatar
Martin
12/27/2008
hi, how can normal local development be done normally?

and what about the database? ....a fundamental thing I'd say or not!?
Gravatar
Martin
12/30/2008
This tutorial lacks some basic issues

1) how to deal with databases
2) which is the default page.... uploaded an index.aspx page and getting an error &quot;The URL http://www.mywebsite.comindex.aspx did not respond.&quot; - notice without the backslash what I'm missing?
3) On facebook itself there is the DataStoreAdmin ? what's that?
Gravatar
Scott
1/3/2009
Do you have any tutorials for a Desktop App?

Thanks!
Gravatar
martin
1/7/2009
how to use stylesheets?!

btw how many times is this blog visited?
Gravatar
magnus
1/9/2009
Thanks, great simple article!
One small thing though - the appSettings section in the web.config should be named appSettings (with a capital S). That gave me a build error, when I shamelessly copy/pasted you're code.
Gravatar
Jon
1/9/2009
Anybody know how do fix the initial blank page issue? I have the same issue that Joel mentions above. It doesn't seem to be generating the login form automatically. TIA.
Gravatar
JJ
1/11/2009
Does anyone have a simple implementation of calling an image for the wall-profile box ?
Gravatar
Happy Coder
1/13/2009
This helped me a LOT.

I thought it was MUCH MORE complicated, but things really went smooth after I found the right binaries in the right toolkit.
Gravatar
Mangesh Nerkar
2/3/2009
Thanks for your effort. This is exactly i was looking for.
Gravatar
DE
2/11/2009
I am having the SAME blank page issue which is not redirecting to the login page "http://www.facebook.com/login.php?api_key=keygoeshere&v=1.0&next=default.aspx". Anybodyt figure this out?
Gravatar
Bill Konrad
2/11/2009
For those who are having the blank page issue, it seems to me that Facebook is not redirecting when it hits an fb:redirect tag properly some times. This appears to be intermittent based on the couple of you who had issues. Please download the sample and try it out, I have checked it multiple times.
Gravatar
Sami
2/12/2009
When I build my application I get an error saying:

'facebook.web.CanvasFBMLBasePage.API' is not supported by the language


Now what can it be?
Gravatar
Alan Robbins
2/12/2009
I've spent several hours with two different allegedly simple examples of Facebook applications using .net with zero success. I am very successful at generating "The page you requested was not found" within the facebook environment, and when I ping the application url, I conclude that facebook is right. The http: response stream in Fiddler also confirms that sure enough, apps.facebook.com/MyApplicationName is not a valid url.

I don't get a blank page as others have reported. Something in the app setup is obviously wrong, seriously wrong, but I cannot determine what.

Anyone who has made this downloaded app work, I'd love to hear from you moosemiester at gmail dot com.

I really don't want to switch to php, have too many years in .net (eight)
Gravatar
Alan Robbins
2/17/2009
Update: I have an application that works, kind of. Login is the biggest challenge, I can load it via the app key url approach, but not through the apps.facebook/myappname link that is generated by the facebook interface.

Still looking to commisserate, discuss, and work with others who have a design to do Facebook apps in .net, see my email address in the prior post.

It is slow going, download all the toolkits, look at the http: stream directly, the knowledge comes slowly but it can be done.
Gravatar
Hoang
2/25/2009
Following up! Thanks
Gravatar
john
2/28/2009
How do you do stuff with databases, etc. on facebook with asp.net? Thank you.
Gravatar
Antonio Ferraioli
3/2/2009
Very good!
Thanks
Gravatar
Shedrek
3/3/2009
I am having the same blank page Issue ,FaceBook is not redirecting to the Login page, if i copy the Url on the address bar and after giving uid and pwd ,it shows the content on the page, hmmmm whts the work around of this issue i also used the Bill codebut not getting success..
Any Help in this regard is highly appreciable.
Gravatar
Bri
3/4/2009
I am getting an error when I navigate to the app in Facebook, "Received HTTP error code 500 while loading http://www.u4easerv.com/facebook/aspsample/"

When I go to that page, I get an ASP configuration error, "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS."

The offending line is <authentication mode="Windows" />

Any ideas? (I am an ASP.NET newbie)
Gravatar
Bri
3/4/2009
I fixed that error by making sure my project folder was configured as an application in IIS.

Now I am getting a new error, Could not load file or assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. (D:\WWW\www_u4easerv_com\facebook\aspsample\web.config line 79)

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Gravatar
Bill Konrad
3/4/2009
Bri,

A quick Google search found that it has something to do with VS2008 Beta 2 and caching the wrong binary for .NET 3.5

Please see:

http://www.telerik.com/community/forums/aspnet/ajax/q2-bug-could-not-load-file-or-assembly-system-web-extensions.aspx

and let me know if that clears it up. The error has nothing to do with the Facebook Developer Toolkit.
Gravatar
KC
3/12/2009
I am also getting the blank page issue. Has this been resolved? Any help would be great.
Gravatar
M Sunil Kumar
3/13/2009
nice article
Gravatar
M Sunil Kumar
3/17/2009
Its really a very nice article. I have installed vs 2005 and working on facebook applications. I implemented the sample code which explained in this example. When I run the application, it displays, could not load file or assembly 'System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.

I would be appreciated if anybody helps me out with possible solution.

Regards,
Sunil
Gravatar
Bill Konrad
3/17/2009
Sunil,

You need to make sure you have the .NET framework 3.5 update installed. The missing binary is for LINQ, a feature of the newest version of the framework.

Let me know if this solves your problem.

Thanks,

Bill Konrad
Gravatar
PxPilot
3/17/2009
The tutorial about Facebook connect worked great for me, but now I am trying to create a canvas app and I keep getting:
Error while loading page from MySite.com
The URL http://localhost:50044/MySite/Default.aspx is not valid.

I used the sample in the tutorial and just changed the APIKey, Secret and Callback in the web.config. The only thing that might be a problem for it is the localhost anyone knows how to solve it?

Thanks
PxPilot
Gravatar
John
3/28/2009
It seems like a lot of the properties are not properly implemented? Am I doing something wrong, or is this true?

When I do this:
Response.Write(API.users.getInfo().hometown_location);

I get this:
FBML Error (line 1): unknown tag "hometown_location"
Gravatar
John
3/28/2009
How do you get the hometown and current locations of the current user and their friends?

Is this possible with current .net API?

Thanks!
Gravatar
yoshi
4/6/2009
thanks for the article!
Gravatar
Stan
4/6/2009
This is exciting stuff. Thanks for the article and thanks to the developers of the .NET API. I'm versed with ASP.NET development but am stumped trying to get a simple example working.

For those of you following along with the example above you'll want to use AppSettings in Web.Config instead of APPSETTINGS (XML is case sensitive.)

I've attempted to create a Canvas application. When the user logs in I can see the user profile information in my code behind but Facebook isn't drawing the page. Users receive the follwing error:

Errors while loading page from application
Received HTTP error code 404 while loading http://zzz.dyndns.org/site/fd/fd/Default.aspx?auth_token=888...


The problem is with the path. Facebook is appending an extra "fd/" onto the correct URL. I've tried many different URLs for the various settings to no success.

Something that isn't clear in .NET API articles is when instructions address the Callback URL within web.config vs the Callback URL defined in the Facebook settings. Has anyone else experienced this problem?

Perhaps everyone else is creating examples immediately off of the root directory. Any help will greatly be appreciated!

Thanks in advance,
Stan
Gravatar
kiki
4/8/2009
Great articles...
Gravatar
Muhammad Ahmed
4/11/2009
WHat's for classic ASP :P
Gravatar
Jonathan Wood
4/11/2009
I am working on an app and everything was working great, then I now get that same blank page everyone keeps talking about. What appears to be happening is that it is failing to redirect the user when require login is set to true and they never get the authenticate question or allow question for the application. Has this ever been fixed?
Gravatar
piripitsis
4/13/2009
zip is unavailable -- can you make it available again?
Gravatar
Raul Macias
4/17/2009
Link to the sample code is broken.
Gravatar
Daniel
4/22/2009
I too am getting the blank page that has the FBML code in the source. And yes, the sample code link is dead ;)

Gravatar
test
4/23/2009
Thankyou !
Gravatar
Anand
4/28/2009
Link to the sample code is broken. Can any body give me working link

Thanks
Gravatar
Joseph Anderson
5/14/2009
Hey,

For a C# example, take a look at my blog:

http://blogs.sitefinity.com/JosephAnderson/Posts/09-05-13/Facebook_C_Sitefinity_Integration.aspx
Gravatar
Nitish
5/18/2009
The sample code link doesn't work. Please look into it.
Gravatar
alberto
5/20/2009
YOUR SOURCE CODE DOWNLOAD LINK... DON'T WORK!!!
Gravatar
fixyourlink
5/22/2009
fixyourlink
fixyourlink
fixyourlink
fixyourlink
fixyourlink
fixyourlink
fixyourlink
fixyourlink
fixyourlink
fixyourlink
fixyourlink
fixyourlink

:)
Gravatar
Bill Konrad
5/27/2009
My apologies guys. The link is now up and working.
Gravatar
rajesh
5/29/2009
HI Guys i am facing the same problem of blank page i am using the version of dll 1.7.0.0 please guide me new to face book application

Thanks in advance
Gravatar
Noor Khan
5/30/2009
anyone knows how can i use facebook connect in my vb.net web application
Gravatar
Shakeeb Ahmed
6/3/2009
Hi,

I want to know how to use MasterPage with Canvas Frame using FBML.

I tried many ways but no luck its urgent..

Thanks
Gravatar
name
6/4/2009
This comment form fails hard w/ no name or email address set
Gravatar
HeartDisk
6/18/2009
i implemented but its have lot of problems
Gravatar
Justin Toth
6/25/2009
Terrible article, leaves out too many important steps, like how to test it locally (pushing your code to a live server after every change is not ok) and how to actually make it work (gives generic error if set to FBML, gives blank screen if set to IFrame.)
Gravatar
Ð? Van V?ng
7/15/2009
C?m on nhé, mình cung dang háo h?c tham gia c?ng d?ng facebook dây :))
Gravatar
Jonathan
7/20/2009
I've found an issue with the ConnectAuthentication class. If I connect using the method described in this blog post, everything seems to work. Then if I open facebook in another window and log out of facebook in that window, the cookies in my application still show that I am logged in even though I am not. The first time I try to access something in the api that requires a login, such as first name, it throws an exception. Is there a good way to modify the class so it verifies that the user is still logged in?
Gravatar
Mike
8/5/2009
Anyone know how you can test this locally? When I try to set up and FBML site to localhost or 127.0.0.1, I can a message from Facebook saying it's an invalid url.
Gravatar
Mynk Lee
8/9/2009
I try to use your example, but when it run, just a white webpage.
I don't know while! Please help me!

I try to write a desktop application. And I have an exception: "Requested value '...' was not found". Please help me!

Thanks!
Gravatar
Newbie
8/17/2009
Hi,

I am new to this.
I have a GoDaddy Windows Web hosting account which can obviously serve up aspx pages.
I am getting the following error:
Compiler Error Message: CS0246: The type or namespace name 'facebook' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 10: using System.Web.UI.WebControls.WebParts;
Line 11: using System.Xml.Linq;
Line 12: using facebook;
Line 13: using facebook.web;
Line 14:

This compiles and runs fine on my local machine.
Please help

Nitin
Gravatar
fauzievolute
8/18/2009
I need help, I use my linux server and use php to work. What is facebook toolkit can be used there?
with the following example from the sample code???

please any one with solution for me. i'm newbie for this and i need more about this.

contact me at: fauzievolute@gmail.com
Gravatar
AnonyMOOSE
8/21/2009
follow instructions +
coffee =
BLANK PAGE!
Gravatar
Hmedia
8/21/2009
I am using IList 'facebook.schema.user' f = API.friends.getUserObjects();"
It keeps asking for uid or session key,
I tried setting both with API.uid and API.sessionkey....but it keep asking???
Any idea how to get the list of friends?
Gravatar
Bob
8/24/2009
Hi, The smaple seems simple, however I'm getting that Error 500. Now this is happening with any example I used. I sure enough people have run into this error that a list of troubleshooting or try this is avaiable somewhere.

It was a great step by step.

Gravatar
Chacha DeJava
8/26/2009
Thanks!
Gravatar
Tiago Andrade e Silva
8/27/2009
Blank page issue also. Any solution ?
Gravatar
Dan R
8/31/2009
For those getting a 405 error. face. I was able to resolve the problem by entering the entire path of my Default.aspx page in facebook.com/developer canvas callback url. For example http://www.yourwebsite/applicationname/Default.aspx
Gravatar
Bharat
9/1/2009
Hi,

My requirement is to develop a web application, which run as a standalon application. I mean user is not required to login to facebook.com. It can access the data available at facebook for a perticular user. that means user profile, friends list, and most importantly the comment etc.

No worries we will have the credentials (username/password) of the user with us.

can anyone help me out doing this. I am really in urgency.

Thanks.
Gravatar
Dave
9/2/2009
Worked fine for me right out of the box.
Gravatar
Shoaib
9/3/2009
Great article.. got my first facebook app up and running in no time. Thanks
Gravatar
meir r
9/10/2009
Hi

Great Beginning explanation!

I downloaded your sample code and updated the web.config with my fb api info when I run the application on fb i get the following

Compiler Error Message: CS0012: The type 'facebook.API' is defined in an assembly that is not referenced. You must add a reference to assembly 'facebook, Version=2.0.3230.29787, Culture=neutral, PublicKeyToken=null'.


What am i missing here??

Regards

Meir R.
Gravatar
Alexey
9/16/2009
For testing it locally modify your hosts file (C:\WINDOWS\system32\drivers\etc\hosts).

Add the following string there:
127.0.0.1 fakelocaldomain.com

After that use http://fakelocaldomain.com instead of http://localhost or http://127.0.0.1

Also, don't forget to reboot the PC after editin' hosts file. Modify Connect URL at the FB application settings.
Gravatar
ksuvalk
9/16/2009
2 quick questions:

1) when testing locally I just get a blank page and view source shows the fb : redirect source. I can hit the url and it works fine (have it staged on a server as well); so what's my issue on tetsing locally? I did actually set up fakelocaldomain.com but to no avail

2) how do I test the app up on facebook? How does the app get added to http://apps.facebook.com/appname? Or is there another way to test it up on facebook?

Thx look forward to playing!
Gravatar
ksuvalk
9/16/2009
I figured out my question 2) above. I was using the wrong appname and I think I didn't give it time to propagate. I can hit it now.

So my only remaining question is: how to successfully test the app locally instead of a blank page?!

Help? Thx :)
Gravatar
David Moore
9/21/2009
it would be great if you would provide a simple example of a framed .net application using XFBML.
Gravatar
Harish Singh
9/29/2009
I cant the login page of facebook after running the above code.
any help would be appreciated
Gravatar
rakesh
10/14/2009
your code is good and fine working.but how can set permissions for status update after this setting update status.
plz send code
Gravatar
McCodeJunky
10/24/2009
Great article. I got this up and running in 10 mins and very happy. Thanks!
Gravatar
frank
11/1/2009
It seems that I also have the same problem with the blank page. Is there allready a solution for this?

Gravatar
WYSIWYG
11/5/2009
New to ASP.net. This works fine locally, but when I put it on the server I get:

Compiler Error Message: CS0246: The type or namespace name 'facebook' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 10: using System.Web.UI.WebControls.WebParts;
Line 11: using System.Xml.Linq;
Line 12: using facebook;
Line 13: using facebook.web;
Line 14:

Do I have to create strong name key files and add the dlls to the Global Assembly Cache or am I missing something else? Thanks
Gravatar
WYSIWYG
11/5/2009
Solution: Made facebook folder an application in order for it to work.


How to do this:
1. Start IIS Manager
2. Locate the facebook staging folder and choose properties
3. Click the "Create" Button next to the grayed "Application Name" field
4. Done
Gravatar
craig
11/11/2009
why am i getting all these error message ?
Warning 1 Validation (): Element 'html' occurs too few times. C:\Documents and Settings\EMMA\Desktop\facebook sdk\Source\Default.aspx 7 9 C:\...\Source\
Warning 2 Validation (XHTML 1.0 Transitional): Element 'form' must be included within a parent element. C:\Documents and Settings\EMMA\Desktop\facebook sdk\Source\Default.aspx 3 2 C:\...\Source\

etc etc

thanx
Gravatar
snookerbottoms
11/13/2009
hi
Gravatar
Better tutorial
11/29/2009
Go here for a better tutorial. It'll take a little longer to read through but well worth the effort:

http://fbtutorial.qsh.eu/default.aspx
Gravatar
Chris
12/1/2009
I can't seem to get the proxied_email property to show in intellisense. Is it there?
Gravatar
Jess
12/11/2009
Is there any samples of posting to a group page using stream.publish anywhere? Every time I try calling the API.stream.publish with the group id in it and the user id, I get an error
Gravatar
Varun Sood
1/7/2010
Great article. Concise and Compact....That is all you need to get people follow you....Great help...Thanks....
Gravatar
Ganesh Gadge
2/8/2010
I need to use this type of application with PHP for my website. Can i get a source code for that ?
Gravatar
Samuel_Cazelli
2/12/2010
When I try this:

Bitmap image = API.users.getInfo().picture;

I always get a picture with question mark. Even if the user have a picture...

Someone know why?
Gravatar
Rich
3/8/2010
Tried to get example to work in 2.0 and recently-released 3.0 (with suitable modifications). I am not redirected to the facebook login page.

My browser source shows the fb:redirect tag with url of http://www.facebook.com/login.php?api_key=99999cc&v=1.0&canvas"


Am I missing something obvious?
Gravatar
Utku Bilgin
3/16/2010
Any wall post (stream.publish) examples please?
Gravatar
Lisa
3/17/2010
Regarding the blank page: I think this is what's going on. I had this too. Check that you haven't selected IFrame instead of FBML for your canvas page. I got a clue from the Facebook ASP.Net Facebook Tutorial (http://fbtutorial.qsh.eu/section1/fbml/step5.aspx):

"If you select IFrame instead of FBML in your applications settings, you are expected to return a standard html page to the Facebook server. Facebook will not process the code of the html page returned at all."

This implies that while your ASP.Net app is happily generating the fb:redirect tag, it will not be processed by the Facebook servers, and hence you get nothing rendered into the canvas page.

When I changed my app from IFrame to FBML, it did try to process the code, but now I can't use my local server (defined in the hosts file). I got this error:

Errors while loading page from application
The URL http://local.mytestappserver.com/fbapp/ did not respond.


Gravatar
prateek saluja
5/1/2010
Thanx.
Gravatar
Rich Rodgers
5/27/2010
Thank you for posting this! Elegant solution, and it got me into the castle for the first time. I can stop tearing my hair out!
Gravatar
unknown
5/28/2010
fuking nice article. thanks man.
Gravatar
LOST
6/10/2010
How to solve fucking "The type or namespace name 'Facebook' could not be found" problem ?
Gravatar
LOST
6/10/2010
Your captcha is so stupid anyway i wanna answer my own question("The type or namespace name 'Facebook' could not be found" ).You need to add reference by right clicking to the references .Right click references > select add reference > add dll files from where you extracted your FDT files (bin folder i guesss ) then add them .Ta daaa problem solved.
Gravatar
COLMAN
6/10/2010
This shit is out of date !
Gravatar
Isuruanu
6/16/2010
Hi

I dont have my own website to publish my apps. Is there any substitution for this. I not able to register my own website.
Gravatar
Adriana Murillo
6/23/2010
I have my business page and I want to meke it look better, but I have a problem, Im using Photobuket to upload the pictures and then getting the HMTL code to paste it on my facebook page. I im using the FBML application to add tabs to my front page and then pasting the code there. It looks great but I have a problem, the picture on my profile contains a hiperlink that take all users to the photobucket album I have. and I dont want that to happend. I want the image to display more content inside myu one facebook page, not to take my fans somewhere else.

And this is the page Im trying to fix: http://www.facebook.com/pages/MercaIdeando/132729916754477?v=app_7146470109

I want it to do someting like this: http://www.facebook.com/Marketwire
Gravatar
pat capozzi
7/5/2010
I am getting

"The name 'API' does not exist in the current context" on the default.aspx page
code.
Hello, <%= API.users.getInfo().name %>

Any suggestions would be GREATLY appreciated.

PatC
Gravatar
Emre Çelik
7/17/2010
Hi everybody!

I want to update my facebook status via asp.net but i cant do it.I need sample code
Please help...
Thanks in advance!
Gravatar
sayed
7/26/2010
I am getting

"The name 'API' does not exist in the current context" on the default.aspx page
code.
Hello, <%= API.users.getInfo().name %>

Any suggestions would be GREATLY appreciated.

sayed
Gravatar
Usman
7/28/2010
Sayed & PatC,
According to my understanding API here..
Hello, <%= API.users.getInfo().name %>
...
is Belong to Facebook.Reset.Api

so the this is correct one..

Hello, <%= Facebook.Reset.Api.users.getInfo().name %>
Gravatar
KV
8/16/2010
Hi all,
Can we create business facebook account for user on his behalf for him using facebook api.
thank you

regards,
KV
Gravatar
Chetan
8/24/2010
Hi,
i read those steps but can anyone tell me how i use this api for VC++????
i have to use this in mfc application where i will ask for publish on facebook......then
if yes then open browser and ask for login after that the hardcoded message will be shared on that wall.........

if no than exit.....


please help me!!!!!

Thanks in Advance :-)
Gravatar
Ooolalashop.com
8/24/2010
Great post, is it outdated with the new API though?

Harry
Ooolalashop.com
When you think Thong, think Ooolalashop.com!
Gravatar
Carlos
10/21/2010
I was wondering, on the Facebook Developers page. Do i have to submit my application to the application directory in order for me to work with the Fbtoolkit?
Gravatar
satyendra singh
10/29/2010
pls tell how to show current status of logged user in face book api intregation
Gravatar
socialcubix.com
12/6/2010
Informative article on hoe to use the facebook developer toolkit
Gravatar
mobilecubix.com
12/6/2010
First i Thank to Author.who give me nice information on Facebook developer toolkit.I know you put more article on facebook
Gravatar
arti
1/6/2011
Can u plz tell me how to connect VC++ MFC application to facebook. how can i access facebook directly through a single button from my appliction.....
Gravatar
reza nazari
1/15/2011
Im working with VS2008.
-------------------------------------
Setting are these:
SiteUrl : http://localhost:57344/YourName/
CanvasUrl : http://localhost:57344/YourName/
CanvasPage : http://apps.facebook.com/rezadaily/
webconfig : Callback value="http://localhost:57344/rezadaily/
----------------------------------------
my browse address :
http://localhost:57344/YourName/Default.aspx
----------------------------------------
but the browser has Nothing...
statusbar : Done
-----------------------please guide me
Gravatar
Nelson
2/11/2011
Hi there,

I found a good example for a desktop app using c# and it connects perfect, but I want to do the same with an asp.net file, but I don't know how to throw a link for the oAuth and get it back, in the desktop example there is an object that launch and event when it completes the login step, it got the token to keep the connection alive, I tried to use server.transfer and response.redirect, but those methods don't return any value, do you have any suggestion??? Thank you!!!
Gravatar
arindam
4/19/2011
Hi Nice Article,

But i am not able to see the result as the following two property not getting the right value, sessionkey is always null and userid is always 0,

what do i need to do to make it work ?

public string SessionKey
{
get
{
string _skey = GetFacebookCookie("session_key");
return _skey;
}
}

public long UserID
{
get
{
long userID = -1;
long.TryParse(GetFacebookCookie("user"), out userID);
return userID;
}
}

private string GetFacebookCookie(string cookieName)
{
string retString = null;
string fullCookie = Setting.ApiKey + "_" + cookieName;
if (HttpContext.Current.Request.Cookies[fullCookie] != null)
retString = HttpContext.Current.Request.Cookies[fullCookie].Value;
return retString;
}
Gravatar
pankaj dixit
6/23/2011
Hi Nice article but i m facing a issue with this that
its giving an error :The type or namespace name 'API' could not be found (are you missing a using directive or an assembly reference?)
if (ConnectAuthentication.isConnected())
{
API api = new API();

api.ApplicationKey = ConnectAuthentication.ApiKey;
................
................
................
}
Gravatar
Ninad
7/13/2011
Hi i am using VS 2005

The name 'API' does not exist in the current context
Gravatar
ElvisJ
8/16/2011
Hi Bill Konrad and everyone!

I get the following error on implementing this article, although on the article before I was able to create the "connect" test page with the same API Key with no errors and it authenticated for me:

facebook.Utility.FacebookException: Invalid API key

What did I miss?
Gravatar
Denno S
10/17/2011
thank you for the great tutorials and for the sample code great help indeed .
Gravatar
Murimi
10/20/2011
Try this
Api.Users.GetInfo().name

instead of API.users.getInfo().name
Gravatar
sandeep
12/11/2011
thanks all to solve problems
Gravatar
Dennis Layante
12/14/2011
Any sample codes using FB developer toolkit
in vb.net?
Gravatar
chandu
2/7/2012
The error i am getting is-- The name 'API' does not exist in the current context.

What is this API??You dint mention in your whole tutorial.
Gravatar
zakaria
4/18/2012
the API doesnt exist error is due to misspelling: it should be "Api"
Gravatar
Angela
5/9/2012
This is really wonderful exciting that compelled me to comment.
http://www.socialcubix.com
Gravatar
Diego
5/21/2012
Hi, this is what i was looking for, but I have an error.
on "Api.users.getInfo().name"
the word Api appears underline and says it doesn't appear in current context.. it says "Facebook.Rest.Api" I am missing something? I have a reference to Facebook.dll and Fecebook.Web.dll. I am working with Visual Studio 2008.
thanks!!!
Gravatar
Danilo Oliveira
11/27/2012
Terrible Article!!! Very Terrible...
Gravatar
ghfgh
11/29/2012
fsdfd f
Gravatar
Muhammad Hamid
11/4/2013
Problem ! i have downloaded dll of both facebook and facebook.web . but code is still not working. ConnectAuthentication , API, Facebook these words are being undelined by compiler. kindly give link of dll
Gravatar
Amit
12/27/2013
Hi,
I have clicked on facebook developer application, but i have not seen the 'Set Up New Application' option there ti create
my app. Is this form changed now to another link?
I have already created developer account but not seen the option
('Set Up New Application')to create application.
Please help me.

Thanks.
Gravatar
ahmed
1/16/2014
API ?? not defined
what is API ?
'API' couldn't be found ??
Add a Comment

Name

Email Address

1 + 1 = ?

Comment










iphone application development konrad group
android application development konrad group
windows phone 7 development konrad group