0

I am using facebook connect to allow users to log-in to my site using facebook. I am using the server side authentication using OAuth in classic ASP, vbscript. I want to know if one of the following is possible:

1) Can I identify if the user has authorized my app without redirecting to the Auth dialog? ie, even before the user clicks the facebook login button to log-in to my site, is there a way I can find out if the user who is currently logged into facebook has authorized my app?

2) How can I get the facebook user Id of the user who is currently logged into facebook? This is outside the facebook authentication process. Does facebook offer some api which I can use to read the fb cookie that is set when a user logs into facebook and get the logged-in users's facebook user id?

Thanks

Pia Palackathadom
  • 95
  • 1
  • 4
  • 12

1 Answers1

1

1) Use FB.getLoginStatus from the JavaScript SDK.

2) If he’s not connected to your app yet, then not at all. Otherwise, see 1)

CBroe
  • 91,630
  • 14
  • 92
  • 150
  • Thanks for the suggestion. I used FB.getLoginStatus() and it works fine if the user is logged into facebook. But, if the user is not logged into facebook, then FB.getLoginStatus() callback is not called and I am not able to handle that case in my code because I dont get a callback. Please help. – Pia Palackathadom Jun 29 '12 at 13:34
  • Another strange thing I noticed is the flow when calling FB.getLoginStats(). I noticed that the code after the call to FB.getLoginStatus() is executed before FB.getLoginStatus(). Sample Code: alert("before FB.getLoginStatus()"); FB.getLoginStatus(function(response) { alert("inside call back function");}); alert("after FB.getLoginStatus()"); When logged into fb, I get the alerts in this order (1)before FB.getLoginStatus() (2)after FB.getLoginStatus() (3) inside call back function. When NOT logged into fb, I get the alerts in this order (1)before FB.getLoginStatus() (2)after FB.getLoginStatus(). – Pia Palackathadom Jun 29 '12 at 14:24
  • `FB.getLoginStatus` is an asynchronous method as it has to fetch the status from Facebook, the entire continuation of your code branch therefor have to be executed in the context of that callback. – Sean Kinsey Jul 01 '12 at 01:43
  • Thanks Sean. But the call back is not called when the user is logged out of facebook. Is there a way around that? Please help. I am stuck with this issue for the past few days. – Pia Palackathadom Jul 02 '12 at 13:15