如何“喜欢” Facebook 外部内容

发布于 2024-10-15 01:22:25 字数 1525 浏览 4 评论 0原文

所以我一直在尝试使用 facebook like 按钮,但遇到了问题。我有一个关于我在这里所做的一些慈善工作的 Facebook 页面:

http://www.facebook.com/Adam .Holmes.Climbs.Kilimanjaro

我还有一个网页,上面有几乎相同的信息。在此网页中,我有一个类似 facebook 的按钮,以便用户可以喜欢该页面,如下所示:

http:// Developers.facebook.com/docs/reference/plugins/like/

现在我的问题是一个单独的按钮。在 Facebook 页面中,我添加了一些用户“喜欢”和评论的图像等。我现在已将这些相同的图像放置在我的网页上,我想为每个图像添加一个类似 facebook 的按钮,从而显示所有喜欢的按钮该图像在 Facebook 上有。我已将许多不同的链接插入“喜欢”按钮,但似乎都不起作用。我已经尝试过 a) 页面的 url。 b) 图片的 URL。 c) 操纵不同 url 的随机位和蝙蝠。

我试图查看 javascript 源代码,但它对于我的理解来说太复杂了。我知道从按钮调用函数 fc_click() ,该函数进一步调用另一个函数,不久之后我就迷路了,没有找到使用的 url。

所以我想我的问题是,要放置在“喜欢”脚本中的网址是什么,以便我可以在 facebook 外部使用“喜欢”按钮?

如果需要更多信息,请说出来。

非常感谢:)


更新:我一直在尝试所有不同的组合或 URL,但仍然没有运气。其中一个“喜欢”按钮的对象是图中的一个对象,即 这是我想要喜欢的对象。 但没有这些链接有效。也许 facebook 对此进行了限制,因为使用页面的 url 很简单并且工作正常,只是不是单个项目。

我可以再次补充一点,我需要放置在标签中的链接,而不仅仅是能够检索喜欢和评论的计数等。我还在 Facebook 开发者论坛上启动了一个主题 此处,但没有人回复解决方案。

再次感谢。


更新2: 正如“Myles Gray”所指出的,代码实际上在 HTML 中呈现为:

我不确定是否有一种方法可以从外部页面访问表单,因为它没有正确的 this 引用。有人能够阐明这是否可以做到吗?如果可以,如何做到?当然,如果可以做到这一点,正确引用 this 将使我能够喜欢外部内容。

So I have been playing around with the facebook like button but I have run into a problem. I have a facebook page about some charity work I'm doing here:

http://www.facebook.com/Adam.Holmes.Climbs.Kilimanjaro.

I also have a web page that has pretty much the same information on it. Within this web page I have a facebook like button so that users can like the page as seen here:

http://developers.facebook.com/docs/reference/plugins/like/.

Now my issue is with a seperate button. Within the facebook page I have added images of which some users have "liked" and commented etc. I have now placed those same images on my web page where I would like to add a facebook like button for each image and hence displaying all the likes that the image has on facebook. I have plugged many different links into the like button but none of them seem to work. I have tried a) the url of the page. b) the url of the image. c) random bits and bats manipulating different url's.

I attempted to look through the javascript source code but it is much too complicated for my understanding. I know that a function fc_click() is called from the button which further calls another function, and not long after that I get lost, and have not found what url is used.

So I guess my question is, what is the url to be placed in the "like" script so that I can use the like button externally to facebook?

If anymore info is needed, please say so.

Thank you very much :)


UPDATE: I have been trying all different combination's or URL's and still having no luck. The object for one of the "Like" buttons is an object in the graph i.e. Here is the object I want to like. but none of these links are working. Maybe facebook are restricting this as it is simple to use the url of the page and it works fine, just not individual items.

May I add again that I need the link that is to be placed in the tag and not just to be able to retrieve a count of the likes and comments etc. I also started a topic on the facebook developer forums here but no-one has replied with a solution.

Thanks again.


UPDATE 2:
As pointed out by "Myles Gray" the code is actually rendered in the HTML as:

<label onclick="this.form.like.click();">

I'm not sure if there is a way to access the form from an external page since is wouldn't have the correct this reference. Is anybody able to shed some light on whether this can be done, and if so, how? Surely if this can be done, having the correct reference to this would allow me to like content externally.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

陪我终i 2024-10-22 01:22:25

我认为使用 不可能在非页面内容上获得 Facebook Like 按钮。为了测试这一点,我在自己墙​​上发布的照片​​上尝试了一些操作。正如您所发现的,所有 URL 都不起作用。

也就是说,您可以构建自己的“点赞”按钮。借助 Graph API,您可以使用 /me/feed 从您自己的 Feed 中提取对象。最简单的事情可能是使用提要中的图像;如果您托管图像,则需要一个映射表返回到提要上的对象。您的提要中的每个对象都会有一个“赞”计数器。

更新

重新阅读该帖子,看起来您不希望用户必须登录。可以从服务器端调用 Graph API。当您访问自己的 Feed 时,您只需授予应用对自己的 Feed 的离线权限,当前用户无需登录。

更新 2

它显示为 / POST_ID/likes 仅适用于帖子 - 我在其他任何内容上都会收到“应用程序必须位于白名单上”的信息。

I don't think getting a Facebook like button on a piece of content that's not a page is possible with <fb:like>. To test this out, I tried a couple things on a photo I posted on my own wall. As you figured out, none of the URLs work.

That said, you can build your own like button. With the Graph API, you can pull objects from your own feed with /me/feed. The easiest thing would probably be using images from the feed; if you hosted the image you'd need a mapping table back to objects on your feed. Each object from your feed will have a Like counter.

Update

Reread the post and it looks like you don't want the user to have to log in. The Graph API can be called from the server side. As you're accessing your own feed, you just need to give your app offline permissions to your own feed, and the current user won't have to log in.

Update 2

It appears /POST_ID/likes only works on posts - I get "app must be on whitelist" on anything else.

愿得七秒忆 2024-10-22 01:22:25

恐怕您想要的不可能是不可能的。一个快速的“证据”:

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like href="http://www.facebook.com/platform" show_faces="true" width="450"></fb:like>

这会工作得很好,但使用其图形 API 解释:

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like href="https://graph.facebook.com/19292868552" show_faces="true" width="450"></fb:like>

这行不通!

我认为您不应该费心寻找“解决方法/黑客”或尝试检查和调试 facebook 上的照片页面,因为甚至如果您确实找到了方法在外部使用他们的类似功能,我很确定这会让您陷入 Facebook 的法律问题!

现在我要做的是,监控用户何时“喜欢”您网站上的照片,并在“喜欢”按钮下弹出一个弹出窗口或一个 DIV,以鼓励他前往 Facebook 中的照片页面那里也支持它(喜欢它)!

这可以通过使用 edge.create 事件来完成:

FB.Event.subscribe('edge.create', function(response) {
  // Encourage the user to support your cause in Facebook too!
  $("div_with_a_link_to_the_photo_page_on_facebook").show();

  // or using a dialog or whatever effect you like
  $("#facebook_support").dialog();
});

PS:我在这里使用 jQuery

另外,为了真正喜欢外部的 facebook“对象”,您需要一个应用程序和类似的东西我的答案这里,但我认为你不想要这样做。

I'm afraid what do you want is not possible. A quick "evidence":

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like href="http://www.facebook.com/platform" show_faces="true" width="450"></fb:like>

This would work just fine, but using its Graph API interpretation:

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like href="https://graph.facebook.com/19292868552" show_faces="true" width="450"></fb:like>

This won't work!

I don't think you should bother searching for a "workaround/hack" or trying to inspect and debug the photo page on facebook, because EVEN if you did find a way to use their like functionality externally I'm pretty sure that would get you into legal issues with Facebook!

Now what I would do is, monitoring when the user "likes" a photo on your website and have a pop-up or a DIV under the LIKE button to encourage him to go the photo page in Facebook to support it (like it) there too!

This can be done by using the edge.create event:

FB.Event.subscribe('edge.create', function(response) {
  // Encourage the user to support your cause in Facebook too!
  $("div_with_a_link_to_the_photo_page_on_facebook").show();

  // or using a dialog or whatever effect you like
  $("#facebook_support").dialog();
});

P.S: I'm using jQuery here

Also to actually like facebook "objects" externally you need an application and something like my answer here, but I think you don't want to do that.

时光清浅 2024-10-22 01:22:25

我想指出的是,这是一个非常混乱的想法混搭,而不是一个完整的解决方案。我建议您坐下来花点时间研究 Facebook 文档

请查看此处。正如您所看到的,facebook 中的每个对象都是 Graph API 的一部分。因此,它有自己的唯一 ID 和属性。根据照片,您可以查看此处,看到每张照片都有自己的唯一的 ID。

因此,您需要做的是每次加载网页时从该特定页面调用该特定相册中的特定照片,因此,您将能够提取 Facebook 上收到的这张照片的所有评论和点赞。

我想说最好的方法是初始化 JavaScript SDK< /a>,对特定的 你想要的图片,并获取数据。

现在-按照显示:由于facebook没有有一个特殊的插件来在外部网页上显示照片,所以显示部分是棘手的部分。所有信息都以 JSON 对象形式接收,您可以按照您想要的任何方式显示该对象。我建议,为了让体验更具社交性,为每张照片创建一个“点赞”按钮,并在 Graph API 中使用该照片的 ID。 文档位于此处

I'd like to point out that this is a very messy mash-up of ideas to go about this, and not a complete solution. I would advise to sit down and crack your head open on the Facebook Docs for a little while.

Please look here. As you can see, every object in facebook, is part of the Graph API. As such, it has it's own unique ID an properties. As per photos, you can look here and see that each photo has it's own unique id.

So-what you need to do, is call that specific photo from that specific album from that specific page each time your web page is loaded, and as such, you will be able to pull all the comments and likes this photo received on Facebook.

I'd say the best way to go about this is to initialize the JavaScript SDK, perform an FQL query on the specific picture you want, and get the data.

Now-as per displaying: Since facebook does not have a special plugin to show photos on external web pages, the display part is the tricky part. All the info is received in a JSON object, which you can display in any way you want. I would suggest, to make the experience more social, creating a like button for each photo with the id of that photo in the Graph API. Docs are here.

浅听莫相离 2024-10-22 01:22:25

AFAIK Facebook 使用一个内部统计计数器,该计数器以某种方式链接到带有照片 ID 和相册 ID 的 photo.php...

如果您查看源代码,您可以看到(喜欢它):

<label onclick="this.form.like.click();"><i class="img sp_29yryj sx_182771" title="Like this item"></i></label>

以及进一步(查看人们)谁喜欢它):

<a href="/browse/?type=likes&id=1516817795900" rel="dialog" ajaxify="/ajax/browser/dialog/?type=likes&id=1516817795900" title="See people who like this item">16 people</a>

如果你能以某种方式根据图像 ID 找出 URL 是什么,你应该进行排序,TMK FB 似乎正在使用某种自定义库来喜欢图像的 ID。

AFAIK Facebook uses an internal stat counter that is somehow linked to the photo.php with the photo ID and album ID...

If you look at the source code you can see (To like it):

<label onclick="this.form.like.click();"><i class="img sp_29yryj sx_182771" title="Like this item"></i></label>

And further along (To view the people who liked it):

<a href="/browse/?type=likes&id=1516817795900" rel="dialog" ajaxify="/ajax/browser/dialog/?type=likes&id=1516817795900" title="See people who like this item">16 people</a>

If you can somehow work out what the URL is based on the image id you should be sorted, TMK it seems FB are using some sort of custom library to like the image's ID.

oО清风挽发oО 2024-10-22 01:22:25

使用like插件:(

    <div class="fb-like" data-href="**http://graph.facebook.com/[object_id]**" data-send="false" data-width="270" data-show-faces="false" data-colorscheme="dark" data-font="arial"></div> 

只需输入你自己的对象id)。我的问题是,我无法弄清楚如何检测用户是否已经喜欢该对象而无需登录到应用程序(而不仅仅是登录到 Facebook)。

为此,您的应用程序需要 Extended_permissions,例如在本例中它需要 read_stream 权限。完成后,您可以使用 fql 查询类似的表。

Using the like plugin:

    <div class="fb-like" data-href="**http://graph.facebook.com/[object_id]**" data-send="false" data-width="270" data-show-faces="false" data-colorscheme="dark" data-font="arial"></div> 

(just put in your own object id). My problem is that I can't figure out how to detect if the user has already liked the object without being logged into an app (not just logged into fb in general).

To do this your app requires extended_permissions eg in this case it needs read_stream permission. Once you have that you can query the like table with fql.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文