I downloaded the Facebook C# SDK 4.1.1, and incorporated it on a small ASP.NET 3.5SP1 web project. When I run the application from VS Studio 2008, it allowed me to install my Facebook application. When I log onto facebook, I can see that my app installed, as I see it on my home page left nav.
When I click on the app, it displays the default.aspx page on my facebook app iframe. Looks like it worked, right? No it doesn't because when I debug the page on localhost, I see that the Authorize() on the CanvasAuthorizer app returns FALSE.
I created a web app in IIS 5.0 so that the default vs studio debugger doesn't interfere.
Here are they facebook settings I have set and other relevant information.
Any help is greatly appreciated!
Thanks!
Canvas Page "http://apps.facebook.com/mynewapp/"
Canvas URL http://localhost/MyNewApp/
Canvas FBML/iframe iframe
My Page Load:
protected void Page_Load(object sender, EventArgs e)
{
fbApp = new FacebookApp();
authorizer = new CanvasAuthorizer(fbApp);
authorizer.Perms = requiredAppPermissions;
if (authorizer.Authorize())
{
ShowFacebookContent();
}
}
Here are the relevant sections of my web.config:
Found out the issue:
http://adamyoung.net/IE-Blocking-iFrame-Cookies
The issue was only happening in IE. IE blocks iframe cookies...have to set the header to allow cookies.
来源:https://stackoverflow.com/questions/4618767/canvasauthorizer-authorize-not-returning-true-on-facebook-c-sharp-sdk