问题描述
我的网站上有一组页面,这些页面使用FBML方法插入FB Recommend按钮.我的问题是,我网站上的每个页面都显示完全相同的推荐计数(即使我刚刚安装了按钮,"557个人推荐此页面"),并且当我尝试自己推荐它时,它就会显示在我的新闻提要中错误的页面标题,错误的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标记(我用匿名值替换了这些标记,以防止客户端看起来像个白痴开发人员);)
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>
...然后在页面的后面(我使用FBML方法的唯一原因是,我可以跟踪google Analytics(分析)中的推荐事件-这应该无关紧要,但出于全面披露的目的,我也在此处包含该代码)...
...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>
我的Feed中显示的链接是 http://abc.xyz.com/path/to/my/(URL的最后一段丢失),标题是旧的;我意识到在设置时所有页面都具有相同的标题,因此我给它们起了不同的标题.我已经通过URL linter运行了几个URL,并且没有错误,并且所有数据看起来都是正确的.
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.
推荐答案
这里有两个注释:
- 由于您使用URL Linter检查了多个URL,并且结果如预期的那样出现,这意味着这是一个缓存问题,请阅读.
- 如果您不使用Facebook Graph API ...或除Like插件以外的任何与Facebook相关的服务,则不需要第一个Facebook Javascript初始化代码段,但如果使用了它,则不需要(
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
). /li>
- Since you checked several URLS using the URL Linter and the result came up as expected this means it's a caching problem, read this.
- If you are not using Facebook Graph API...or any Facebook related services other than the Like Plugin, then the first Facebook Javascript initialization snippet is not needed but if it's used then (
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
) is not needed.
根据评论,某些页面有50多个赞,这意味着您无法再更改title
:
Based on the comments, some of the pages have more than 50 likes this means you can't change the title
anymore:
来源 .
但是,如果您确实需要更改title
,并且可以确定可能失去喜欢的人数,那么可以在末尾添加一个假参数元标记的标签,以便Facebook 认为是一个新页面:
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:
http://www.domain.com/page.php?123
请注意,我从未在新的Like插件中使用过此技术.
这篇关于< fb:like>遇到问题页面标题,如计数和页面网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!