Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

Does it treat them as different pages to 'like'?

for example if i get 4 like clicks:

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?

like image 252
Haroldo Avatar asked Aug 12 '10 11:08

Haroldo


2 Answers

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>
like image 124
Mike Sherov Avatar answered Oct 12 '22 10:10

Mike Sherov


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">
like image 28
Salvatore Avatar answered Oct 12 '22 10:10

Salvatore