ria
ria

Reputation: 811

Why is my facebook Iframe application showing empty canvas

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());
    }

Upvotes: 1

Views: 1130

Answers (1)

Henry Mori
Henry Mori

Reputation: 51

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!

Upvotes: 2

Related Questions