views:

2384

answers:

4

I'm creating a desktop application in C#. one of the things that this application should do is to publish things to the status of the user in facebook (like: "dave just won 3 gold medals" ). this should happen whether the user is logged in now to facebook or not. I want the user to give me all the needed permissions once and then everything would happen automatically (I would save whatever is needed on my DB). I tried using facebook developer toolkit 2.0 for .net but didn't see anything there that could help me. ANY help would be appreciated.

+2  A: 

i think you should start to look here http://wiki.developers.facebook.com/index.php/ASP.NET

facebook has an elegant .net api

VP
+2  A: 

Hi

as VP said the http://wiki.developers.facebook.com is a good start.

For you question: you need to use the Facebook Connect API

  • there is a Feature called offline_access - its an extended permission.
  • In FB Connect you need to toggle the correct popup :
  • The workflow will be like that:
    • User uses FB Connect to confirm the fact he wants to connect your app to his facebook account.
    • You trigger the popup.
    • You can then call all calls on his permission even if he is offline (or not using facebook connect)

For the sake of understanding: FB Connect is meant that way that you can easily log the user into his app and do everything on his behalf. offline_access is actually meant for cronjob work.

Edit: i have overread the point about the fact that you do a Desktop App.

Maybe these wiki posts are helpful to you:

Andreas Klinger
thanks. can you tell me if (and how) this can be done via the developer toolkit ?
Hagai
sorry i have only hands-on experience with fb connect and canvas apps
Andreas Klinger
i added some links regarding desktop apps - hopefully they help you anyhow
Andreas Klinger
thanks a lot. I'm using your links and other resources to complete this. I'll try to put the finished code here.
Hagai
A: 

ok guys. Iv'e got some answers here. I think it answers other questions I saw in the web lately:

My answer is related to desktop applications that works outside of facebook (facebook connect). + I'm using the facebook developer toolkit 2.1:

here is how to get the special permission, needed to for offline access. and how to get the session key:

facebook.Components.FacebookService FS = new facebook.Components.FacebookService();
FS.GetExtendedPermission(facebook.Types.Enums.Extended_Permissions.offline_access);

/*the second line will force you to login and afterwards would ask for the permission
after the user choose to grant the permission, you are given in the post URL - the fb_si_session_key. BUT the toolkit developers didn't do enough to bring it to you :-(.
so you have few options. the simple one is to do-*/

 FS.Logoff();
FS.ConnectToFacebook();

/*what will happen is that you'll see the login screen for a second and before youll be able to click anything it would vanish. but this time you'll have the right session key. you can get it like that:*/
string myPermanentSessionKey =  FS.API.SessionKey;

/*if you dont want to show that annoying screen again you have few options, all of them are related to changing the source files of the toolkit. I'm not gonna get into it here, but just tell you a simple option:
in the facebookconnect() function I changed it to receive a parameter (isShow) when I send true to it, it behaves normal, when I send false to it - it skips on the formLogin.ShowDialog(); */

it's working guys.

Hagai
one more thing. after you give the permission , facebook tells you to close the window. but if you do that - it raises an exception. this is AGAIN because of the toolkit. I handled it with try catch. waiting to have a better toolkit sometime in the future or fix it myself when i'll have time
Hagai
now that I'm more experienced in facebook, I believe there are better ways, anyhow now theres the new API so everything here becomes old. especially when they'll throw away the old API. like twitter are doing this days.
Hagai
A: 

Hi, I am also trying to create a desktop C# application access facebook when the user is offline. I request for offline_access, and I try to use the session key so that the user does not have to login again but i always get session invalid error. maybe i am doing some thing wrong.

will appreciate if you can elaborate how you managed to do it. regards, rnv

rr
I guess you dont need an answer, now that the new API came to the rescue...
Hagai