我正在尝试在我的网页上实现Like按钮。
这些页面代表产品的评论页面。当用户喜欢该页面时,它会显示在Facebook中(不是作为链接,而是喜欢实体),但是当您点击Facebook中的实体时,它会链接到代表该页面的facebook.com托管页面。我希望将用户重定向到og:url页面?
例如,当您喜欢Grroveshar上的艺术家页面时,会发生这种情况:http://grooveshark.com/#!/artist/Elbow/4795
我显然“做错了”。
我使用以下标记来包含SDK。 MYAPPID包含在Facebook提供的代码生成器中,因此我认为它是必需的。
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=MYAPPID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
然后我的代码呈现Like按钮。
<div class="fb-like" data-send="false" data-width="450" data-show-faces="true"></div>
最后我的og标签:
<meta property="og:title" content="My product" />
<meta property="og:type" content="product" />
<meta property="og:url" content="http://site.com/product_1/" />
<meta property="og:image" content="http://site.com/image1.jpg" />
<meta property="og:site_name" content="My-Site-Name.com" />
<meta property="fb:admins" content="MYFACEBOOKID" />
<meta property="fb:app_id" content="MYAPPID" />
谢谢!
答案 0 :(得分:1)
听起来你把这个URL的管理页面与URL本身混淆了,但我可能错了,因为管理页面顶部有一条消息,解释这个如下所示:
只有管理员才会看到Facebook管理页面,其他用户将返回到所喜欢的网址上定义的og:url
值。如果您没有在HTML5 Like插件中指定data-href参数,那么这将是当前页面或当前页面元标记上og:url
值的任何内容
检查Facebook's Debug Tool对您想要的网址所说的内容,并确保正确读取代码
答案 1 :(得分:0)
groovehark示例的问题在于他们正在使用#!
网址。如果你喜欢http://grooveshark.com/artist/Elbow/4795
,那么它会正常工作。如果您使用此类URL模式而不是遇到问题,则需要覆盖类似按钮以在没有它的情况下点击URL。