【问题标题】:Facebook social plugin in Android application like 9gagAndroid 应用程序中的 Facebook 社交插件,如 9gag
【发布时间】:2013-05-27 18:54:07
【问题描述】:

我正在尝试在 webview 中实现 facebook 社交插件,就像在 cmets 中的官方 android 9gag 应用程序一样。

我正在加载到 webview 中的 html 看起来像这样

<html>
<body>
<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
  FB.init({
      appId      : '$APP_ID$',                      // App ID from the app dashboard
      channelUrl : '$DOMAIN$/channel.php',            // Channel file for x-domain comms
      cookie       : true,
      status     : true,                                 // Check Facebook Login status
      xfbml      : true                                  // Look for social plugins on the page
    });


// 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.async=true; js.src = "//connect.facebook.net/cs_CZ/all.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk')); 
</script>

<div class="fb-comments" data-href="$FB_SOCIAL_URL$" data-width="470" data-num-posts="10"></div>
</body>
</html>

但是当我将它加载到 webview 中时,什么也没发生。当我在桌面上使用它时,也没有任何反应。仅显示空白屏幕。我还尝试从这个答案Android unable to implement facebook comment in a webview due to default browser 实现 webview 的设置,但它并没有改变什么。我不想使用该 facebook 插件加载所有 url,而只想加载该插件本身。有任何想法吗?

【问题讨论】:

    标签: android html webview facebook-social-plugins


    【解决方案1】:

    我会将社交部分分开并使用 facebook 的 android sdk。用户可能不使用 facebook 的移动浏览器。如果使用fb android sdk,体验会好很多。

    如果你仍然想这样做,一件事:你缺少右括号

    window.fbAsyncInit = function() {
    

    【讨论】:

    • 我考虑使用 facebook graph api 并自己实施该讨论。无论如何,谢谢..不幸的是,那个丢失的括号没有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多