How to Make the Facebook Like Button Work Again
I just realized that the Facebook Like buttons on my website don’t work as they should any more. Instead of the button only the word Error was displayed. Clicking on this not very specific error indication led me to a pop-up window, where I was told that “The href URL must be absolute”. Can’t you be a little more precise, dear Facebook? Fortunately the problem is easy to fix.
A quick Google search revealed the solution: Obviously Facebook wants the URL of the liked page not to be passed in URL encoded format any more. I can’t think of a good reason why this change was necessary. Since it was not communicated – at least I haven’t come across an official announcement –, probably lots of websites will suddenly find their like buttons not working properly.
Anyway, the fix is easy to implement. If Facebook doesn’t like URL encoding anymore, so be it. On my website, as well as in projects for clients, I like to use an extended version of the popular jQuery plugin socialSharePrivacy. That is necessary because German data privacy regulations forbid using the standard embed codes directly.
If you use any of the various forks and variations of the socialSharePrivacy plugin, you can quickly fix the URL encoding problem. Just search for the following line:
var fb_enc_uri = encodeURIComponent(uri + options.services.facebook.referrer_track);
Replace it with this line of code:
var fb_enc_uri = uri + options.services.facebook.referrer_track;
That’s it. From now on your Facebook Like buttons work again exactly the way they should.
Write a comment
Your e-mail address will not be published.