我使用 HotTowel SPA 模板启动了一个新的 Visual Studio 2012 Express Web 项目。我不确定在 HotTowel 结构中加载 Facebook SDK 的代码应该放在哪里?
我已经尝试过 main.js 和 shell.js,但我似乎无法加载 sdk。Facebook 说要放置下面的代码来异步加载 sdk
window.fbAsyncInit = function () {
// init the FB JS SDK
FB.init({
appId: '577148235642429', // App ID from the app dashboard
channelUrl: '//http://localhost:58585/channel.html', // Channel file for x-domain comms
status: true, // Check Facebook Login status
xfbml: true // Look for social plugins on the page
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK asynchronously
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all/debug.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));