javascript - How to fully load ALL of facebook's JS features onto Connect website -


Well, here I am trying to integrate a website with Facebook connect and I have some weird ring of hell I'm stuck in / P>

I have seen 2 ways to start JS on an FBC site, I have tried both frequently, but they do only to meet the partial requirements of the whole work.

  & lt; Script src = "http://connect.facebook.net/en_US/all.js" & gt; & Lt; / Script & gt; ... $ (document) .ready (function () {FB.init ({'appId': '000', 'cookie': true, 'status': true,});});  

This is what authoritative documentation does, however, it does not load all the features. FB.Connect is undefined, make sure nothing does and I have been screwed. I have seen other code

   

It looks good for the first time, because it connects the FB. Connect features ... but it seems that this is the only set of features that it loads as FB.ui, is undefined, FB.getLoginStatus is undefined, and all other "core functions" are undefined ...

Trying to include both different JS files leads to strange errors and half the initial session, I'm not sure what the difference is between 2 different types of FB Indit calls ...

Thank you!

The first example is the "new way" of doing things in the new API Describe (several months ago), while the second example is what the old API was (now deprecated)

The best way to load FB JS is now:

  & lt; Div id = "fb-root" & gt; & Lt; / Div & gt; & Lt; Script & gt; Window.fbAsyncInit = function () {FB.init ({appId: 'your app id', status: true, cookie: true, xfbml: true}); }; (Function () {var e = document.createElement ('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document .getElementById ('FB-root'). AppendChild (e);} ()); & Lt; / Script & gt;  

Which prevents the page from loading until JS is loading.

Unfortunately there is no way to get the best from both worlds, and if you have a new API, then possibly possible for new projects sooner or later it will be dropped for new projects.

You can find new API documents. 90% of the old APIs were taken to the facilities (often under different names), but some older stuff like FB.ensureInit () are actually missing. Apart from this, some older API features need to be used now.


Comments