1

I have created an asp.net facebook application with an iframe, it used to show up correctly on the url http://apps.facebook.com/myappname until i placed the code to add permissions on the page. I used facebook.dll to use the facebook.Components.FacebookService class and checked the authentication token etc using this class. Ever since i have done this the application canvas page shows up as empty. However, when i enter the actual site url in the browser location bar which i have used as the canvas url (e.g. http://myappname.mydomainname.com) i see the prompt with the application requesting the permissions. Can someone please guide where m i doing it wrong.

   _fbService.ApplicationKey = FACEBOOK_API_KEY;
        _fbService.Secret = FACEBOOK_SECRET;
        _fbService.IsDesktopApplication = false;
        string sessionKey = Session["Facebook_session_key"] as String;
        string userId = Session["Facebook_userId"] as String;
        // When the user uses the Facebook login page, the redirect back here
        // will will have the auth_token in the query params
        authToken = Request.QueryString["auth_token"];
        // We have already established a session on behalf of this user
        if (!String.IsNullOrEmpty(sessionKey) && !String.IsNullOrEmpty(userId))
        {

            _fbService.SessionKey = sessionKey;
            _fbService.uid = Convert.ToInt64(userId);
        }
            // This will be executed when Facebook login redirects to our page        

        else if (!String.IsNullOrEmpty(authToken))
        {
            try
            {
                _fbService.CreateSession(authToken);
                Session["Facebook_session_key"] = _fbService.SessionKey;
                Session["Facebook_userId"] = _fbService.uid;
                Session["Facebook_session_expires"] = _fbService.SessionExpires;

            }
            catch (Exception)
            {

                Response.Redirect(@"http://www.Facebook.com/login.php?api_key=" + _fbService.ApplicationKey + @"&v=1.0\");
            }
        }
        // Need to login        
        else
        {
            Response.Redirect(@"http://www.Facebook.com/login.php?api_key=" + _fbService.ApplicationKey + @"&v=1.0\");
        }

        facebook.Schema.user usr = _fbService.users.getInfo();
        //User usr = _fbService.GetUserInfo();
      //  string t = string.Format("User Name:{0}, Sex:{1}, Location: {2}", usr.first_name, usr.sex, usr.current_location.city);
        GetUsersFriendsList();
        // GetUserName(usr);
        // SetControlVisibility(_fbService.uid.ToString());
    }
ria
  • 819
  • 5
  • 19
  • 40

1 Answers1

2

With these sorts of problems, it's best to determine early on whether the issue you are having is due to a client-side i.e. JavaScript issue or a server-side issue.

Let's start with client-side troubleshooting:

  • Open the Developer Console for your browser (e.g. CTRL+SHFT+I in Chrome on PC)
  • Do you see any errors in red text as per my screenshot below? If so, can you let us know what they are please?: Browser console with error

You say the problem(s) started once you started to use permissions - with the Facebook API, these are mainly requested client-side using the JavaScript API, so I am thinking that it's best to start there as a possible root area of the problem.

Let us know your findings and we'll troubleshoot from there!

Henry Mori
  • 51
  • 4
  • With chrome i see only this error in console > Refused to display document because display forbidden by X-Frame-Options. – ria Jan 17 '12 at 08:55
  • With firefox firebug i see this error > uncaught exception: Error: Permission denied for to get property Proxy.InstallTrigger ... but as i researched this error some places said its a bug in firebug itself – ria Jan 17 '12 at 08:57
  • @ria, well, it looks as though it *may* be HttpRequest header related as the iFrame is not displaying correctly, hence the Chrome error and the blank canvas when the page loads. These posts may be of interest: http://stackoverflow.com/a/6767901/730133, http://stackoverflow.com/questions/6666423/overcoming-display-forbidden-by-x-frame-options/6767901#6767901 – Henry Mori Jan 17 '12 at 11:42
  • Also, there may be an exception tripping in the _fbService.CreateSession(authToken); method of the try statement which is preventing the SessionKey, uid and SessionExpires parameters from being set properly, which would lead to authentication errors. Are you able to debug locally and set a breakpoint in VS to see what's going on in the method mentioned above? – Henry Mori Jan 17 '12 at 11:45