Friday 15 January 2010

javascript - See if user logged on to facebook -


I am trying to use Facebook API to see if the user is logged on to my site or not .

When I call FB.getLoginStatus, I do not get any feedback. I tried about each example code, I received a response and did not find anything. Does anyone help me find out the problem with my code:

  & lt; Div id = "fb-root" & gt; & Lt; / Div & gt; & Lt; Script type = "text / javascript" src = "// connect.facebook.net/en_US/all.js"> & Lt; Script type = "text / javascript" & gt; Window.fbAsyncInit = function () {FB.init ({appId: 'my_app_id', // App ID status: true, // check login status cookie: true, // allow server to use session xfbml Enable cookies for: true // parse XFBML}); }; // Load Asynchronous SDK (function (D) {var js, id = 'facebook-jssdk'; if (d.getElementById (id)) {return;} js = d.createElement ('script'); js Id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; d.getElementsByTagName ('head') [0] .appendChild (js);} (document) )); Function GetFBLoginStatus () {debugger; Window.fbAsyncInit () Warning ("Get Status"); FB.getLoginStatus (function (in the "call back function"); if (response.status === 'connect') {warning ("log");} and if (response.status === 'Not_authorized') {Warning ("Not authorized");} Other {Warning ("Logout");} Veracity Back;}, True)} < / Script & gt;    

There are no closed tags for your first script:

  & lt; Script type = "text / javascript" src = "// connect.facebook.net/en_US/all.js">   

should be

  & lt; Script type = "text / javascript" src = "// connect.facebook.net/en_US/all.js" & gt; & Lt; / Script & gt;   

Right now, the browser is thinking that the second script is part of the tag script which is defined in your first script tag. You parse errors and the rest are not executed.

No comments:

Post a Comment