Facebook喜欢按钮,喜欢索引/列表页面上的单个内容项 [英] Facebook Like button to like individual content items on an index/list page

查看:103
本文介绍了Facebook喜欢按钮,喜欢索引/列表页面上的单个内容项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望实现一个包含内容列表的页面,显示每个页面的标题和摘录。我们希望在每个内容项旁边都有一个Like按钮,当单击时,单击喜欢单个项目,而不是索引页面。

We wish to implement a page with a list of content items, showing a title and excerpt for each one. We want to have a Like button next to each content item, which, when clicked, "likes" the individual item, rather than the index page.

我们已经看到在其他地方实现了这一点(以前的Mashable.com,在他们的主页),但是使用标准的实现,我们无法让它工作。有人有任何提示吗?

We've seen this implemented elsewhere (formerly Mashable.com, on their homepage), but using a standard implementation we can't get it to work. Does anybody have any tips?

我们正在使用PHP / Symfony。

We are using PHP/Symfony.

注意:我不是一个程序员,所以这个问题不是用技术语言来构建的 - 但是任何答案都将传递给能够理解他们的程序员。

NB: I'm not a programmer so this question isn't framed in technical language - however any answers will be passed to programmers who will be able to understand them.

推荐答案

您只需要在页面上的每个相似按钮上设置href属性。例如,

You just need to set the href attribute on each like button on your page. For example,

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like href="http://www.example.com/item1"></fb:like>
<fb:like href="http://www.example.com/item2"></fb:like>
<fb:like href="http://www.example.com/item3"></fb:like>

如果每个按钮都有自己的href,那么每个按钮都将独立运行。如果您不包括href,那么相似的按钮假定您喜欢正在查看的当前页面。

If each button has its own href then each button will behave independently. If you don't include the href then the like button assumes you are liking the current page you are viewing.

此外,您应该在每个网址上实现开放图协议你有一个喜欢的。这个我的意思是你的按钮的href中的url,而不是类似的按钮所在的页面。您可以在这里阅读: http://developers.facebook.com/docs/opengraph

Additionally, you should implement the open graph protocol on each url you have a like for. By this I mean the url in your like button's href, not the necessarily page the like button is on. You can read about this here: http://developers.facebook.com/docs/opengraph

这很简单。您只需将元标记添加到您的网页标题,如下所示:

It is pretty simple to do. You just add meta tags to your pages header like this:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://opengraphprotocol.org/schema/"
      xmlns:fb="http://www.facebook.com/2008/fbml">
  <head>
    <title>The Rock (1996)</title>
    <meta property="og:title" content="The Rock"/>
    <meta property="og:type" content="movie"/>
    <meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
    <meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
    <meta property="og:site_name" content="IMDb"/>
    <meta property="fb:admins" content="USER_ID"/>
    <meta property="og:description"
          content="A group of U.S. Marines, under command of
                   a renegade general, take over Alcatraz and
                   threaten San Francisco Bay with biological
                   weapons."/>
    ...
  </head>
  ...
</html>

这篇关于Facebook喜欢按钮,喜欢索引/列表页面上的单个内容项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆