Rest.Api - ConnectSession vs. DesktopSession

Dec 9, 2009 at 2:29 PM
Edited Dec 9, 2009 at 2:32 PM

The following works like a charm:

Facebook.Session.ConnectSession connectSession = new Facebook.Session.ConnectSession(Settings.Default.api_key, Settings.Default.secret);
Facebook.Rest.Api Api = new Facebook.Rest.Api(connectSession);
Api.Session.SessionKey = "[sessionKeyHere]";
Api.Session.UserId = [UserId];

string name = Api.Users.GetInfo().name;

On the other Hand, I receive an error message "invalid signature" if I try this:

Facebook.Session.DesktopSession desktopSession = new Facebook.Session.DesktopSession(Settings.Default.api_key, Settings.Default.secret, "[sessionKeyHere]");
Api = new Facebook.Rest.Api(desktopSession);

name = Api.Users.GetInfo().name;

What am I doing wrong?
I'm using the latest Version of the Toolkit (Changeset 39697).

Dec 9, 2009 at 3:46 PM

I don't know if it is a factor, but one guess is that in your Facebook app settings there is a setting to indicate if your app is a desktop app or a web app.  Maybe if you try to establish a desktop session when Facebook thinks your app is a web app, it might not work and give this error.  Just a guess.

Dec 10, 2009 at 10:05 AM

Good point, thanks :)

My app needs to be a web app, so I have to use the ConnectSession?
I've also tried Facebook.Winforms.Components.FacebookService, but I don't understand how to set the secret key there...

My desktop application worked fine with the 2.x version of the toolkit and the related facebook service component.
Now I've switched to 3.0 and the facebook service doesn't work anymore (incorrect signature; no wonder without a secret key). If I switch to Rest.Api with ConnectSession, I can make my Api calls again like I used to, but the overall speed is a pain. With the 2.x service my Api calls took about 3 seconds, now I'm wainting up to 2 minutes. Why is this?

Thanks in advance.

Dec 10, 2009 at 4:37 PM

2 minutes seems crazy slow.

I have a desktop console app that I run from my home PC over relatively slow DSL, do several ConnectSession Rest.api calls, and several LINQ queries/updates per user (to a hosted SQL Server that is across the internet from me).  It averages 2 - 5 seconds per user as I loop through all of my users..albeit this is skewed to the low end as I don't do unnecessary actions on users whose time hasn't come to have actions taken.  But 2 minutes would seem way out of line.  

I don't have a solution for you, just the information that your slow performance seems to be unusual.