sig*_*gil 26 javascript facebook facebook-javascript-sdk
我正在尝试从Facebook JS SDK的文档中运行第一个示例.我创建了一个新的应用程序,创建了一个名为"facebookTest.html"的空白文档,粘贴在示例的代码中,并插入新应用程序的App ID.代码如下:
<html>
<head>
<title>Login with facebook</title>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : 'my app ID', // App ID from the App Dashboard
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK's source Asynchronously
// Note that the debug version is being actively developed and might
// contain some type checks that are overly strict.
// Please report such bugs using the bugs tool.
(function(d, debug){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = document.location.protocol+"//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
</script>
Run Code Online (Sandbox Code Playgroud)
当我加载页面时,在Javascript控制台上,我收到以下错误消息:
Failed to load resource
我究竟做错了什么?
编辑:当我在此document.location.protocol
之前添加时"//connect.facebook.net/..."
,如此处所示,屏幕保持空白,控制台显示以下内容:
GET file://connect.facebook.net/en_US/all.js
Run Code Online (Sandbox Code Playgroud)
所有这些代码都应该这样做吗?还是它还在失败?
sig*_*gil 40
这里有一些错误:
需要将js.src
作业更改为:
js.src="https://connect.facebook.net/en_US/all.js";
Facebook不再支持从本地文件发出的JS SDK调用,该脚本必须在具有http://
或https://
URI 的文件上运行,根据Facebook上的此错误报告.我需要将文件上传到Web服务器,相应地更改画布URL,然后重新测试.
归档时间: |
|
查看次数: |
41083 次 |
最近记录: |