【发布时间】:2011-04-22 05:51:06
【问题描述】:
我正在实现一个赞按钮,但由于某种原因,元标记中的信息没有正确传输。
如果我将 URL 放入 <fb:like></fb:like> 标签中,则正确的 URL 会加载到 FB 上的墙贴中。但是元标记中描述的图像和所有其他项目不会随它一起发布。如果我将href 排除在<fb:like></fb:like> 标签之外,则链接默认为“赞”按钮所在的页面。不幸的是,我需要在链接中添加一些参数,这样当用户从 FB 帖子点击进入该网站时,它会正确显示。
我已经通过链接 linter 运行我的链接,它仍然在墙上的帖子中显示相同的图像和基本站点信息,而不是 linter 中显示的元标记中的图像或描述。
基本上,我的一些元信息似乎被忽略了。我究竟做错了什么?这是缓存问题吗?
编辑我刚刚在 IE 中测试了这个,我得到一个错误,应该是喜欢按钮的地方,说找不到页面...
文档的头部:
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta property="og:title" content="Product Title" />
<meta property="og:type" content="product" />
<meta property="og:url" content="http://www.mysite.com/folder/folder/gateway.cfm?ifcn=1&fbx=true&type=product&product=771&page=gateway" />
<meta property="og:image" content="http://www.mysite.com/folder/folder/images/theImage.jpg" />
<meta property="og:site_name" content="My Site" />
<meta property="fb:admins" content="ADMIN_ID123" />
就在body标签内:
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
我的赞按钮:
<fb:like href="http://www.mysite.com/folder/folder/product.cfm?pid=562&ifcn=1&fbx=true&type=product&product=562&page=gateway " show_faces="false" width="450" font=""></fb:like>
【问题讨论】:
-
你的 html 中的 'fb-root' 元素在哪里?
-
@emaillenin,我更新了代码以显示它在我的页面中的位置。就在
body标签的开头之后。 -
我认为你需要这个 doctype 才能使用 opengraph 元标记。 ttp://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd" rel="nofollow" target="_blank">w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> 并尝试修改 xmlns:og 如下 xmlns:og="opengraphprotocol.org/schema"
-
@emaillenin,不走运。我更改了 doctype 和 xmlns:og 声明,但仍然没有运气。我在
FB.init函数中没有 app-id。我将尝试添加一个,看看是否对我有用。 -
还是没有运气。即使有一个appID。事情如此简单,却又如此令人沮丧。
标签: facebook metadata facebook-like