Facebook 'Like' buttons and # URL strings?

前端 未结 3 614
遇见更好的自我
遇见更好的自我 2020-12-29 13:40

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?

Does it treat them as different p

相关标签:
3条回答
  • 2020-12-29 13:46

    Facebook will drop everything following the hash tag. What you need to do is send your request escaping # symbol encoding it in %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">
    
    0 讨论(0)
  • 2020-12-29 13:54

    Facebook's like buttons use metadata that are embedded in the HTML markup of a single page. It would work in theory if your URL's produce different metadata when accessed by curl (i.e. 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).

    So having said that, I would assume that Facebook Like buttons don't behave differently for different hash strings. 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

    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

    UPDATE - Clarifying from the comments

    So, now that we know you have static versions of the hash string URLS. Before, you were most likely placing like buttons on the page with this code:

    XFBML:

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

    Instead, you should be specifying the SEO version of the URL. For example, when you're on mysite.com/articles#story4, the code should look like:

    XFBML:

    <fb:like href="mysite.com/articles/story/4" show_faces="false" width="450"></fb:like>
    
    0 讨论(0)
  • 2020-12-29 13:55

    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.

    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.)

    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.

    0 讨论(0)
提交回复
热议问题