出现问题页面标题、点赞数和页面 url
我的网站中有一组页面使用 FBML 方法插入 FB 推荐按钮。我的问题是,我网站上的每个页面都显示完全相同的推荐计数(“557 人推荐此页面”,即使我刚刚安装了该按钮),当我尝试自己推荐它时,它会显示在我的新闻源中错误的页面标题、错误的 URL,当然,网站上的每个推荐按钮都会递增。这是我的代码:
og 标签(我用匿名值替换了这些标签,以保护我的客户不会看起来像他们有一个白痴开发人员);):
<meta property="og:title" content="XXX page title"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="http://abc.xyz.com/path/to/my/page/"/>
<meta property="og:site_name" content="XXX site name"/>
<meta property="fb:admins" content="xxx my facebook id"/>
<meta property="og:description" content="xxx short description"/>
...然后就在正文中:
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxx',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
...然后在页面中(我使用 FBML 方法的唯一原因是这样我可以跟踪谷歌分析中的推荐事件——这应该是无关的,但为了充分披露,我也在这里包含了该代码)...
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<script type="text/javascript">
FB.Event.subscribe('edge.create', function(href, widget) {
_gaq.push(['_trackEvent', '<?php echo $item->type ?>', 'Facebook Recommend', '<?php echo $item->title ?>']);
});
</script>
<!-- FB LIKE BUTTON INSERTED HERE -->
<fb:like href="<?php echo urlencode('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] )?>" show_faces="false" width="450" action="recommend" font="arial" colorscheme="dark"></fb:like>
链接显示在我的提要中的是 http://abc.xyz.com/path/to/my /(URL的最后一段丢失),并且标题是旧的;当我设置这个时,我意识到所有页面都有相同的标题,所以从那以后我给了它们不同的标题。我已经通过 URL linter 运行了几个 URL,没有错误,并且所有数据看起来都是正确的。
I have a set of pages in my site that are using the FBML method of inserting a FB Recommend button. My problem is that every page on my site shows the exact same recommend count ("557 people recommend this page" even though I just installed the button), and when I've tried to Recommend it myself, it shows up in my news feed with the wrong page title, the wrong URL, and of course, every recommend button on the site is incremented. Here is my code:
og tags (I replaced these with anonymous values to protect my client from looking like they have an idiot developer) ;) :
<meta property="og:title" content="XXX page title"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="http://abc.xyz.com/path/to/my/page/"/>
<meta property="og:site_name" content="XXX site name"/>
<meta property="fb:admins" content="xxx my facebook id"/>
<meta property="og:description" content="xxx short description"/>
...then just inside the body:
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxx',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
...and then later on in the page (the only reason I'm using the FBML method is so I can track the recommend events in google analytics -- this should be unrelated, but for the purposes of full disclosure, I'm including that code here too)...
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<script type="text/javascript">
FB.Event.subscribe('edge.create', function(href, widget) {
_gaq.push(['_trackEvent', '<?php echo $item->type ?>', 'Facebook Recommend', '<?php echo $item->title ?>']);
});
</script>
<!-- FB LIKE BUTTON INSERTED HERE -->
<fb:like href="<?php echo urlencode('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] )?>" show_faces="false" width="450" action="recommend" font="arial" colorscheme="dark"></fb:like>
The link that shows up in my feed is http://abc.xyz.com/path/to/my/ (the last segment of the URL is missing), and the title is an old one; I realized that all the pages had the same title when I was setting this up, and so I gave them different titles since. I have run several of my URLs through the URL linter and there are no errors, and all the data looks correct.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有两个注意事项:
)。
编辑:
根据评论,某些页面的赞数超过 50,这意味着您无法再更改
title
:来源[编辑元标记]。
但是如果您确实需要更改
标题
并且您可以可能失去点赞数,那么您可以添加一个假参数URL 元标记的末尾,以便 Facebook 认为这是一个新页面:请注意,我从未在新的 Like 插件中使用过此技术。
Here are two notes:
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
) is not needed.EDIT:
Based on the comments, some of the pages have more than 50 likes this means you can't change the
title
anymore:source [Editing Meta Tags].
BUT if you really need to change the
title
and you are okay of probably losing the likes' count, then you can add a fake parameter to the end of the URL meta tag so that Facebook thinks it's a new page:Please note that I've never used this technique with the new Like Plugin.