简体   繁体   English

Facebook“喜欢”按钮和#URL字符串?

[英]Facebook 'Like' buttons and # URL strings?

What does Facebook make of 'Like' buttons in a ajax web app if they are referring to the same page but with a different # string? Facebook如果指的是同一个页面但是使用不同的#字符串,那么ajax web应用程序中的'Like'按钮会是什么?

Does it treat them as different pages to 'like'? 它是否将它们视为“喜欢”的不同页面?

for example if i get 4 like clicks: 例如,如果我得到4次点击:

mysite.com/articles#story1
mysite.com/articles#story2
mysite.com/articles#story3
mysite.com/articles#story4

what will come up in the users' newsfeed 用户的新闻源会出现什么

4 people like mysite.com/articles

or 要么

dave likes mysite.com/articles#story1
tom likes mysite.com/articles#story2
ben likes mysite.com/articles#story3
nick likes mysite.com/articles#story4

are there any other things to think about with FB and # strings? FB和#strings还有其他什么需要考虑的事情吗?

Facebook's like buttons use metadata that are embedded in the HTML markup of a single page. Facebook的按钮使用嵌入在单个页面的HTML标记中的元数据。 It would work in theory if your URL's produce different metadata when accessed by curl (ie without JavaScript, which I believe is not possible since the hash portion is not seen server-side, so there is no way to act on hash string values server side). 理论上如果你的URL在curl访问时会生成不同的元数据(即没有JavaScript,我认为这是不可能的,因为哈希部分没有在服务器端看到,所以没有办法对服务器端的哈希字符串值进行操作) )。

So having said that, I would assume that Facebook Like buttons don't behave differently for different hash strings. 所以说,我会假设Facebook Like按钮对于不同的哈希字符串的行为不同。 A look at the facebook documentation (which mostly sucks) doesnt mention this, but the facebook developer forums seem to confirm this: http://forum.developers.facebook.com/viewtopic.php?pid=240151 看看facebook文档(主要是糟透了)并没有提到这一点,但Facebook开发者论坛似乎证实了这一点: http//forum.developers.facebook.com/viewtopic.php?pid = 240151

However, all is not lost. 但是,一切都不会丢失。 You can specify the URL of a like button, so just set the URL to be the SEO-friendly URL of the same page: http://developers.facebook.com/docs/reference/plugins/like 您可以指定类似按钮的URL,因此只需将URL设置为同一页面的SEO友好URL: http//developers.facebook.com/docs/reference/plugins/like

UPDATE - Clarifying from the comments 更新 - 从评论中澄清

So, now that we know you have static versions of the hash string URLS. 所以,现在我们知道你有哈希字符串URLS的静态版本。 Before, you were most likely placing like buttons on the page with this code: 之前,您最有可能在页面上放置如下代码:

XFBML: XFBML:

<fb:like show_faces="false" width="450"></fb:like>

Instead, you should be specifying the SEO version of the URL. 相反,您应该指定URL的SEO版本。 For example, when you're on mysite.com/articles#story4 , the code should look like: 例如,当您使用mysite.com/articles#story4时 ,代码应如下所示:

XFBML: XFBML:

<fb:like href="mysite.com/articles/story/4" show_faces="false" width="450"></fb:like>

Facebook will drop everything following the hash tag. Facebook将删除散列标记后的所有内容。 What you need to do is send your request escaping # symbol encoding it in %23 你需要做的是发送你的请求转义#符号编码它在%23

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fmysite.com%2Farticles%2F%23story1" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:px">

Facebook mostly* supports Google's ajax-crawling spec , so that if the fragment starts with an exclamation mark, then Facebook will do the following conversion for the request, so that the server can get the fragment and serve the expected content. Facebook大多数*支持Google的ajax爬行规范 ,因此如果片段以感叹号开头,那么Facebook将对请求进行以下转换,以便服务器可以获取片段并提供预期的内容。

https://myapp.com/#!/post/2 => https://myapp.com/?_escaped_fragment_=/post/2 https://myapp.com/#!/post/2 => https://myapp.com/?_escaped_fragment_=/post/2

(According to Google's spec the user should never see the ugly url, so i assume that Facebook will always store these urls in the "exclamation mark" format.) (根据谷歌的规格,用户永远不应该看到丑陋的网址,所以我认为Facebook总会以“感叹号”格式存储这些网址。)

Serving the proper content for these requests is often non-trivial. 为这些请求提供适当的内容通常是非常重要的。 See more here . 在这里查看更多。

*The meta tag trigger does not work. *元标记触发器不起作用。 I tested it on 2012/08/18. 我在2012/08/18测试了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM