Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java open graph标记中提供的数据不会使用Like按钮呈现_Java_Facebook Like - Fatal编程技术网

Java open graph标记中提供的数据不会使用Like按钮呈现

Java open graph标记中提供的数据不会使用Like按钮呈现,java,facebook-like,Java,Facebook Like,我希望我的网页上的“喜欢”按钮呈现的像这样,它在评论框下方显示图像、标题和说明。我已经包含了必要的开放图标记,但是Like框只是基本的、开箱即用的,没有任何额外的开放图信息。这是我的代码,正如您所看到的,我已经编辑了我的FB应用程序id,但除此之外,这就是我正在运行的代码: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" id="facebook" class=

我希望我的网页上的“喜欢”按钮呈现的像这样,它在评论框下方显示图像、标题和说明。我已经包含了必要的开放图标记,但是Like框只是基本的、开箱即用的,没有任何额外的开放图信息。这是我的代码,正如您所看到的,我已经编辑了我的FB应用程序id,但除此之外,这就是我正在运行的代码:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" id="facebook" class="no_js" xmlns:fb="http://ogp.me/ns/fb#" xmlns:og="http://ogp.me/ns#">
<head>
    <title>Facebook Test Page</title>
    <link ref="canonical" href="http://localhost/Fbtest.jsp" />
    <meta property="fb:app_id" content="<REDACTED>" />
    <meta property="og:title" content="Facebook Test Page" />
    <meta property="og:type" content="website" />
    <meta property="og:url" content="http://localhost/Fbtest.jsp" />
    <meta property="og:image" content="http://localhost/images/my_family.png" />
    <meta property="og:site_name" content="My Website" />
    <meta property="og:description" content="This is just a test page, for Facebook integration." />
</head>
<body>
    <div id="fb-root"><!-- The JS SDK requires the fb-root element in order to load properly. --></div>
    <script>
        window.fbAsyncInit = function() {
            FB.init({appId: '<REDACTED>', status: true, cookie: true, xfbml: true});
        };
        (function(d){
            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 = "//connect.facebook.net/en_US/all.js";
            ref.parentNode.insertBefore(js, ref);
        }(document));
    </script>

    <h1>Facebook Test Page</h1>
    <p>Here is a picture of my family. This is just a test, for Facebook integration.</p>
    <img alt="My family" src="http://localhost/images/my_family.png"/>
    <p/>
    <fb:like></fb:like>
</body>

Facebook测试页面
window.fbAsyninit=函数(){
init({appId:'',状态:true,cookie:true,xfbml:true});
};
(职能(d){
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=“//connect.facebook.net/en_US/all.js”;
ref.parentNode.insertBefore(js,ref);
}(文件);
Facebook测试页面
这是一张我家的照片。这只是对Facebook整合的一个测试

我在JBoss5.1的Windows7/Intel笔记本电脑上运行这个程序,同时使用IE9和Firefix web浏览器


我感谢你的帮助

如果
http://localhost/Fbtest.jsp
实际上是您正在使用的值,这不起作用-Facebook需要联系该URL来读取标签,因此它需要是一个可公开访问的URL

谢谢。我已经将页面移动到Facebook可以访问的服务器上——我已经通过FB调试器运行页面来验证这一点。不过,我还是得到了一个普通的、老式的按钮。这应该可以正常工作,但是在页面被喜欢之前,不会出现弹出窗口,因为元数据只存储在第一个“喜欢”之后(据我所知),并且没有足够快的速度在第一个“喜欢”时显示出来。谢谢,这正是问题所在。在第一个Like之后,弹出窗口包含了我在opengraph标签中包含的标题、描述和图像。