Appreciate some response from FDT 3.0 developers on what's going on.

Nov 22, 2009 at 6:54 PM

I'd appreciate a response from some of the FDT developers. What is going on with this release? As an officially supported Microsoft toolkit for FB it seems very odd that "half" of the samples don't build. It's almost impossible to get an IFrame to actually get a logged in user. What is going on? What is going on with FQL? When will FDT 3.1 be released with these items fixed??

Nov 22, 2009 at 7:16 PM

I also couldn't figure out how i can sessions and logged in user in 3.0 can any1 send a sample c# code

 

Nov 24, 2009 at 1:41 AM

The IFrame issue is one I have already come across.

 

The problem seems to be that the Toolkit no longer stores and retrieves the users information correctly, such that when you follow a link within the IFrame you can no longer get the user info (ID, session, etc...).

When the user first goes to the application, Facebook sends a whole bunch of fb_sig parameters on the query string to the IFrame, and this works correctly with the FDT correctly retrieving the values from the query string. It then stores these in cookies, but does not get the cookies properly when changing pages.

When you click a link within your IFrame, the fb_sig parameters will no longer be on the querystring (unless you add a hack to add the parameters to the links you need them from). You can of course store the Facebook userid in a session yourself, but this really is something which should be taken care of.

 

I believe there is something about this code which is being iffy: (from within Session/CanvasSession.cs)

 

            bool inProfileTab = HttpContext.Current.Request[QueryParameters.InProfileTab] == "1";
            string sessionKeyFromRequest = inProfileTab ? HttpContext.Current.Request[QueryParameters.ProfileSessionKey] : HttpContext.Current.Request[QueryParameters.SessionKey];
            string authToken = HttpContext.Current.Request[QueryParameters.AuthToken];
            CachedSessionInfo cachedSessionInfo = LoadCachedSession();

            if (!string.IsNullOrEmpty(sessionKeyFromRequest))
            {
                SetSessionProperties(
                    sessionKeyFromRequest,
                    long.Parse(inProfileTab ? HttpContext.Current.Request[QueryParameters.ProfileUser] : HttpContext.Current.Request[QueryParameters.User]),
                    DateHelper.ConvertUnixTimeToDateTime(long.Parse(HttpContext.Current.Request[QueryParameters.Expires])));
            }
            else if (cachedSessionInfo != null && (HttpContext.Current.Request.HttpMethod == "POST" || !string.IsNullOrEmpty(authToken))) // only use cached info if user hasn't removed the app
            {
                SetSessionProperties(cachedSessionInfo.SessionKey, cachedSessionInfo.UserId, cachedSessionInfo.ExpiryTime);
            }
            else if (!string.IsNullOrEmpty(authToken))
            {
                session_info sessionInfo = new Api(this).Auth.GetSession(authToken);
                SetSessionProperties(sessionInfo.session_key, sessionInfo.uid, DateHelper.ConvertUnixTimeToDateTime(sessionInfo.expires));
            }

The LoadCachedSession() is within the IFrameCanvasSession which overloads the CanvasSession methods for IFrame apps, and looks like it should be fine.

There is also some information here: http://facebooktoolkit.codeplex.com/WorkItem/View.aspx?WorkItemId=14435

 

 

Nov 26, 2009 at 7:29 PM

Can anybody please confirm is this strange feature bug which has to be fixed or it is feature of new FDT

Nov 30, 2009 at 12:17 AM

I am going back to 2.1!

This new version 3.0 is so far from ready, it is at best an alpha grade release.

I've spent an entire day just trying to get an existing iframe app on 2.1 to auth and navigate 3 pages with 3.0.
Have not been able to do it.  This was not just bad, this was really^100 bad!

Someone is either laughing their hacker-asses off, or they should be really embarassed.

Nov 30, 2009 at 12:54 AM

I am also having trouble with attempting to follow links in my CanvasIFrameMasterPage based app.  As soon as click a link to another page in my app I am kicked out of the facebook chrome and back to my callback page. It would appear that the CanvasIFrame is only good for one page?

The only way I can get it to work is to tag http://apps.facebook.com/myappname/ on to the front of all of my links

Nov 30, 2009 at 1:00 PM

This appears to have been fixed in the latest version in CVS. I downloaded the latest version from the CVS and did a diff and found a couple of changes relating to the IFrame canvas code. To fix, move the changes across, recompile the dll's then use the new dll's

Mar 2, 2010 at 4:01 PM
Edited Mar 2, 2010 at 4:13 PM

I don't know if it's a good solution or not but here's what I did for Iframe & MVC :

In Facebook\Session\CanvasSession.cs replace

else if (cachedSessionInfo != null && (HttpContext.Current.Request.HttpMethod == "POST" || !string.IsNullOrEmpty(authToken))) // only use cached info if user hasn't removed the app
            {
                SetSessionProperties(cachedSessionInfo.SessionKey, cachedSessionInfo.UserId, cachedSessionInfo.ExpiryTime);
            }

with

else if (cachedSessionInfo != null)
            {
                SetSessionProperties(cachedSessionInfo.SessionKey, cachedSessionInfo.UserId, cachedSessionInfo.ExpiryTime);
            }

In Facebook.Web.Mvc\ControllerExtension.cs replace

public static Api GetApi(this Controller controller, string apiKey, string secret)
        {
            FBMLCanvasSession session = new FBMLCanvasSession(apiKey ?? WebConfigurationManager.AppSettings["ApiKey"], secret ?? WebConfigurationManager.AppSettings["Secret"]);
            return new Api(session);
        }
        public static Api GetApi(this Controller controller)
        {
            FBMLCanvasSession session = new FBMLCanvasSession(WebConfigurationManager.AppSettings["ApiKey"], WebConfigurationManager.AppSettings["Secret"]);
            return new Api(session);
        }

with

public static Api GetApi(this Controller controller, string apiKey, string secret)
        {
	    IFrameCanvasSession session = new IFrameCanvasSession(apiKey ?? WebConfigurationManager.AppSettings["ApiKey"], secret ?? WebConfigurationManager.AppSettings["Secret"]);
            return new Api(session);
        }
        public static Api GetApi(this Controller controller)
        {
	    IFrameCanvasSession session = new IFrameCanvasSession(WebConfigurationManager.AppSettings["ApiKey"], WebConfigurationManager.AppSettings["Secret"]);
            return new Api(session);
        }

Must use [FacebookAuthorization(IsFbml = false)] for the first call of your application (to take the querystring of facebook) and then for other controls that want to use GetApi(), you must place this code too ...

Mar 2, 2010 at 4:42 PM

There is a bug in IFrameCanvasSession too ...

UseHttpSession is used before being defined !