1

I am trying to implement facebook social plugin in webview like official android 9gag app has in comments.

My html which i am loading into webview looks like this

<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>

But when i load this into webview nothing happened. When i use it on desktop nothing happen either. Only blank screen is shown. I also tried to implement settings for webview from this answer Android unable to implement facebook comment in a webview due to default browser bud it didnt change nothing. I dont want to load all url with that facebook plugin but only that plugin itself. Any ideas?

4

1 回答 1

0

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

如果你仍然想这样做,一件事:你错过了右括号

window.fbAsyncInit = function() {
于 2013-05-27T20:05:47.710 回答