How do I use the toolkit with apps.new.facebook.com?

Aug 6, 2008 at 7:44 PM
Is this even possible?

I tried it with 1.6 and it didn't work.  This is what happened :

I went ahead and changed all references in the app and the library from "facebook.com" to "new.facebook.com."

At first I was getting cert errors, because apparently there's no cert for new.facebook.com.  So I went ahead and modified the code so that it never uses SSL. 

However, now I'm getting an error when I try to authenticate.  Here is where I'm getting the error (in FacebookAPI.c) :

        internal void CreateSession() {
            Dictionary<string, string> parameterList = new Dictionary<string, string>(3);
            parameterList.Add("method", "auth.getSession");
            parameterList.Add("auth_token", AuthToken);
            XmlDocument xmlDocument = ExecuteApiCall(parameterList, false);

            _sessionKey = xmlDocument.DocumentElement.SelectSingleNode("Facebook:session_key", NsManager).InnerText; //This is where I get the error
            _userId = xmlDocument.DocumentElement.SelectSingleNode("Facebook:uid", NsManager).InnerText;

            XmlNode secretNode = xmlDocument.DocumentElement.SelectSingleNode("Facebook:secret", NsManager);
            if (_isDesktopApp && (secretNode != null && !string.IsNullOrEmpty(secretNode.InnerText))) {
                _secret = secretNode.InnerText;
            }
            double expires =
                double.Parse(xmlDocument.DocumentElement.SelectSingleNode("Facebook:expires", NsManager).InnerText,
                             CultureInfo.InvariantCulture);

            _sessionExpires = false;

            if (expires > 0)
                _sessionExpires = true;
        }

This is the error that I get : Object reference not set to an instance of an object
Aug 6, 2008 at 9:21 PM
Nevermind.  Just solved this one.  Instead of doing a global search and replace, I changed the FacebookRESTUrl in the Resources for the project from api.facebook.com to api.new.facebook.com.

So, for the people at home, here's how to make the libaray work with api.new.facebook.com :

1) Turn off SSL.  Not terribly secure, but this is only temporary until apps.new.facebook.com becomes apps.facebook.com.  Besides the PHP libarary apparently does everything unencrypted.  To turn off SSL, change the GetRequestUrl function in FacebookAPI.cs so it looks like this :

        internal string GetRequestUrl(bool useSSL)
        {
            string returnValue = Facebook.Properties.Resources.FacebookRESTUrl;
           
            /*if (useSSL) {
                returnValue = returnValue.Replace("http", "https");
            }*/

            return returnValue;
        }

2) Go into the Resources for your project and change the FacebookRESTUrl to api.new.facebook.com

And that, as they say, is that.
Aug 7, 2008 at 4:07 PM
If I switch my facebook profile to the old version and remove my app, reinstalling is absolutely no problem. With the new profile, I get an infinitive loop when I try to install it (the URL changes between www.new.facebook.com/add.php?api_key=mykey and apps.new.facebook.com/add.php?api_key=mykey, but nothing happens).

No one with the same problem here?

Thanks in advance!

Aug 7, 2008 at 4:39 PM
I've got the same issue but have not found a solution yet. If I come across anything I'll let you know. Hopefully somebody else has found this problem and solved it already.
Aug 7, 2008 at 5:12 PM
I found an answer to the looping problem here:

http://forum.developers.facebook.com/viewtopic.php?id=19274


Aug 8, 2008 at 12:09 PM
@ msurel
Thanks a lot! :)