【发布时间】: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