Problem and solution about Facebook Like

Difficulties when Facebook social plugins fail and specifically the Like button. I finally found a solution to the problem.

I’ve been hitting the “Like” button on Facebook for days, as many times as I could, because honestly, I don’t have all the time I’d like to dedicate to these things. In this article I will explain where I am, the solutions I have found so far and leave the door open for your comments and the possibility that someone can shed more light on this matter.

Is the Facebook social button important? Well, I think enough to give it the necessary time to let it work correctly. Just like other social plugins from other platforms, they can give us notoriety and some extra visits.

The Facebook Like Button Problem

We have implemented the “Like” button for a long time and from my tests and the administration of .com, which we carry out on a daily basis, everything worked correctly. Until one day, without much explanation, things are changing and sometimes it doesn’t count likes.

Note: Look at the date of this article, since perhaps in a few days, weeks or months, this post is no longer valid and they have been able to solve these problems from Facebook itself.

Faced with this problem, I have reviewed several things about the implementation of the button and as I say, I have stuck with the bug at times for several days:

First I changed the code of the Facebook social plugin. They offer two possibilities, one with IFRAME and another with “XFBML” Javascript scripting. Both have given me problems. Even the code they provide in the plugin seems to have some error, because I get a “&” instead of an “&” in a URL and that according to my common sense is wrong. But hey, I can be wrong.

I didn’t get anything by implementing codes downloaded again from the Facebook site. But it is that the case is even more strange, because the “Like” button works well in most of the posts, but not in some. In those that it does not work, it simply does not count the vote. When pressing “Like” the counted vote appears for a second and then disappears, discounting the “Like”. Then, in the profile of my Facebook account that ghost “Like” does not appear either.

The strangest thing is that, as much as I search for a pattern that allows me to understand why it works in some posts and not in others, I have not found anything in particular that makes me understand what the error is. That is to say, the posts where it does not work have nothing special that the posts where it does work do not have.

See also  IIFE, closures or just function wrapper in Javascript

Then I have dedicated myself to working with the Firebug, examining the response of the Ajax request given when the button is clicked and if it can give me any clue to know how to recognize this possible cause. I also didn’t get anything clear no matter how hard I examined the response, the HTTP headers, etc. there is nothing that clarifies anything for me.

All in all, I’ve come to realize that no matter how hard I investigate, this button is a black box. If it works, it’s all good, but the moment something doesn’t work, it doesn’t allow you to look inside to find out what’s going wrong. Mind you, I’m not complaining that it’s a black box, on the contrary, that’s how it should be, according to the principle of encapsulation (something desirable in widgets or components), but of course if something doesn’t work you feel frustrated because you don’t know what do.

Solution found! but I still don’t know what’s going on

Well, now I am going to tell you what I have done to make it work, but I warn you that, although I have succeeded, I cannot explain what is wrong. The plugin now “works, works”, but this does not mean that it is fine.

Of course there are the Facebook forums to find solutions to these problems with their plugins. The first thing that reassures me is to see that I am not the only one with this problem. There are several people who experience the exact same thing, that the “likes” are not counted. What is more difficult is to find a discussion in the forum that gives a good solution, mainly because many people who participate are users with the same problem and there are few administrators of the social network that give “official” answers.

But hey, at least I found out the following link: .

On that page we can enter a URL for Facebook to explore it and give us some information about the page. Among the information it gives, it also shows us an implementation of the “Like” button that does work!

I have put that implementation of the button into production on our site and it has worked fine again the button in the url where it didn’t work before. But other posts where it also failed, still don’t work. This makes me understand that there really is a loose bug in the button that is not related to the implementation on our site.

See also  Know if port 80 is busy on Wamp Server

The solution that I have found is to go through the “” each of the posts that I find where the “Like” button does not work. Once the URL of the conflicting post is entered there, the social plugin starts working fine.

Do not think that I am satisfied with the way to solve this problem. At university I was taught precisely that, although some computer program may work, a good solution does not have to have been implemented. I’ll settle for the moment with this way For a few days I settled with this way to validate Like buttons, but I’ll be watching for a few days (or weeks) to see if Facebook publishes any official solution or modifies the “Like” plugin, so that it doesn’t of errors randomly in some posts but for a week we have observed that it is not a definitive solution and that, despite sending the address of our page to URL Linter, sometimes it did not fix the problem, or rather, it did not fix it instantly. After a while of sending the link to the URL Linter did work, but with it the solution seemed even worse. I also commend myself to the readers of this article who may have other experiences and have come up with other more interesting solutions. Fortunately, we have found another much more attractive solution, thanks in part to the comments of the people who have read this text.

Facebook Open Graph META Tags

After a week of experiences based on the previous URL Linter solution, we have received several comments that have given us clues as to what might be going on. In Goyito’s comment, he refers to some META tags that we really didn’t have on the page either. In the URL Linter gave us some warnings about the lack of those META, as Goyito himself pointed out.

However, I have to admit that the possible solution was right under our noses. On the Facebook plugin page itself, where you generate the code to insert on the web, a little further down they talk about a “step 2”, with another form to generate a series of META tags to define the “Open Graph Tags”. We’ve included those tags on all articles where the Like button is, and so far everything seems to be working fine.

I hope it’s not another half solution and it’s something we’re going to be watching over the next few days. Of course, if I have other news to communicate, I will update the article.

You can check the source code of this very page to see how we have inserted those META tags, which Facebook seems to be looking for on our pages. You can find those META in the HEAD. However, I’m going to put the code that we are using here, for quicker reference.

See also  Standard screen measurements for your media queries







As I say, you can generate your META from the page to generate the button code. Logically, you will have to customize your META for each article or page where you want to place the button. In the “fb:admins” field you have to put the profile identifier of the page administrators (Facebook users who act as webmasters or editors of your website), separated by commas if there are more than one. That identifier appears in the form to generate the Like button, if you are logged in to Facebook.

conclusion

Well, as you have seen, this article is very much about trial and error. Fortunately I can now write this conclusion because it seems that this solution is definitive. Now, I want to express my dissatisfaction with Facebook for modifying the functionality of the plugin and not warning (if they did notify someone, their way of communicating was quite poor). I also don’t like that they force us to insert new code in all the pages of the site, with META tags that in principle are only there to satisfy their services. It is not that this new code to be inserted in each article weighs much, in bytes, but if we multiply it by several million page views, it is already beginning to be representative.

Apart from everything, that information that we put in the META, until now, they were extracting it through the processing of our pages. Why do we have to make it explicit now? There must be some reason, but I haven’t seen a communication about it either. I understand that it must have something to do with , presented recently. But of course, we, mere mortals who still don’t know all the details of this new Facebook initiative, need more fluid communication so that we don’t hit our heads against the wall because things stop working overnight. the morning and for no apparent reason.

I hope that the problems with this “like” button are easier to solve thanks to this article. For my part, Facebook has earned a “I do not like.” Comments with your experiences and opinions are appreciated.

Loading Facebook Comments ...
Loading Disqus Comments ...