当前位置: 首页 > 知识库问答 >
问题:

使用Facebook的示例代码“加载资源失败”

咸晨
2023-03-14

我正在尝试运行 Facebook JS 开发工具包文档中的第一个示例。我创建了一个新应用程序,创建了一个名为“facebookTest.html”的空白文档,粘贴了示例中的代码,并插入了新应用程序的应用程序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>

加载页面时,在Javascript控制台上,我收到以下错误消息:

无法加载资源

我做错了什么?

编辑:当我在< code>"//connect.facebook.net/... "前添加< code > document . location . protocol 时,如这里所建议的,屏幕保持空白,控制台显示以下内容:

GET file://connect.facebook.net/en_US/all.js  

这就是这些代码应该做的吗?还是它仍然失败?

共有3个答案

连坚白
2023-03-14

首先,您需要将http或https附加到js.src url

其次,您需要在服务器上托管html文件。

邓令
2023-03-14

这里有几件事错了:

>

  • 需要将 js.src 赋值更改为: “https://connect.facebook.net/en_US/all.js”;

    Facebook 不再支持从本地文件进行的 JS SDK 调用,该脚本必须在具有 http://https:// URI 的文件上运行,如 Facebook 上的此错误报告所示。我需要将文件上传到 Web 服务器,相应地更改画布 URL,然后重新测试。

  • 曹均
    2023-03-14

    只需禁用adblock,它为我工作

     类似资料:
    • 我正试图通过Glide将图像加载到。但是图像没有加载-我得到一个错误。我正在使用以下代码 日志

    • 主要内容:资源包搜索顺序,获取资源包,1. 动作类,2. <s:property>标签,3. <s:text>标签,4. Key属性,5. I18n标签要使用资源包从属性文件检索消息,必须了解Struts2的资源包搜索顺序: 资源包搜索顺序 资源包中搜索按以下顺序: ActionClass.properties Interface.properties BaseClass.properties ModelDriven’s model package.properties 搜索国际化消息键的层次结

    • 在project 从服务器链接(.svg)获取 如何下载该给定url的图标,并使用glide在ImageView中显示它? 现在我用的是这样的: 在哪里有: 还添加了下一个类: SVGDRAWABLE转码器: SvgMoules: SvgSoftwareLayerSetter: 但我也只显示选项<代码>数据。logoUrl不为空,但不显示 UPD: W/Glide:加载失败https://mand

    • 我想使用Android版的PDFBox从头开始创建PDF。应显示图像和表格,以及每个页面的重复PDF标题。 我使用的版本是com。tom_roush:pdfbox android:1.8.10.0,可在https://github.com/TomRoush/PdfBox-Android. 所以我克隆了存储库并尝试运行示例代码。Edit1:这是示例代码的链接:https://github.com/T

    • 本文向大家介绍android调用H5显示加载中效果的示例代码,包括了android调用H5显示加载中效果的示例代码的使用技巧和注意事项,需要的朋友参考一下 我们在看有些应用在引入h5的时候经常会有一个进度条在转,显示加载的意思,那么这个东西其实一般是我们android端做的事(不要把所有的事都推给h5~~~),其实实现起来很简单, ok 废话不多说,上代码吧 其中的onPageStarted 和

    • 每当我启动AWS代码构建时,每次都会出现这种类型的错误。请帮忙。 下载源失败3分钟2秒 收到https://github.com/themithunbiswas/test-repo.git/info/refs?service=git-上传包:拨打tcp 192.30。253.113:443:i/o超时