Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在我的网站上使用 Facebook社交插件(Like Box)。我可以看到 Facebook Javascript SDK 也已包含在我的页面中。现在我可以使用了吗?例如,我可以使用这个 sdk 获得粉丝的数量吗?
是的,您只需调用您的页面 ID:
FB.api('/' + pageId, function( r ) { var likes = r.likes });
但是,您必须确保之前已经加载了 FB sdk(如果它是异步加载的)。因此,请确保通过分配一个函数来加载它fbAsyncInit:
fbAsyncInit
window.fbAsyncInit = function () {};
加载 SDK 后将调用此函数。