Facebook like button not working on recent wordpress blog posts

烂漫一生 提交于 2019-12-21 06:31:11

问题


I have a facebook like button on each of my wordpress blog posts, this worked fine up until about 2 weeks ago, and now all recent blog posts don't have functioning like buttons.

This is the response I get when I click the like button (post link)

for (;;);{"__ar":1,"payload":{"requires_login":false,"success":false,"already_connected":false,"is_admin":false,"show_error":false,"error_info":null}}

and for the old blog posts that DO work (post link):

for (;;);{"__ar":1,"payload":{"requires_login":false,"error_info":null,"show_error":false,"node_type":"ExternalLink","node_id":"xxxxxxxxxxxxxxxxx","edge_type":"ExternalLinkLike","connect_text":0,"success":true,"already_connected":true,"user_profile":{"name":"xxxxxxx","profile_url":"http:\/\/www.facebook.com\/xxxxxxx","pic_square":"http:\/\/profile.ak.fbcdn.net\/hprofile-ak-snc4\/xxxxxx_xxxxxxxxx_xxxxxxx_x.jpg"},"story_fbid":"xxxxxxxxxxxxxxxxx","is_admin":false,"admin_url":""},"invalidate_cache":[0]}

I've tried replacing the like box code, removing the href attribute from the like box tag, running each link through Facebook URL Linter and none of this has worked!

I don't understand why it works for old blog posts and not new ones, there are no differences between them (that I know of).


回答1:


Looking at the forums here: http://forum.developers.facebook.net/viewforum.php?id=53

It looks like several other developers are running into the same issue. Some posts there also brought up having to use the lint tool to get their like buttons to work. I've also gotten it to work on my site by just mashing the Like button until it eventually accepts it so like what hpuiu said, i'm pretty confident that this problem's on their end.

Edit: And maybe on a related note, another post said that FB stopped scraping their site until they used the lint tool on their page and another said that they seem to consistently get this issue for any new posts that're around for less than 24 hours.




回答2:


This issue has nothing to do with your code. It is a FB issue I encounter on my websites as well. Did some research and came up with this:

  • this behavior is intermittent, may work on some pages, may fail on others
  • if you go on this page: http://developers.facebook.com/tools/lint/ and enter your url there, first time it will show up an error, afterwards the page will load. Hit some refreshes and afterwards the like button on your site (on the entered url) will suddenly start working... Very weird! I think it has something to do with FB crawler and (maybe) when accessing the lint tool you somehow force the crawler to recheck your page or something.

If anyone finds out something else, please share, the issue is really annoying...




回答3:


You could try to add the Iframe version of the like box instead of their javascript version. Sometimes it actually works better when loading multiple post for example.




回答4:


Facebook doesn't like the '/' at the end of the url. So you can use something like this to omit the '/' at the end of the url :

$title = get_permalink();
<fb:like href="<?php echo substr($title, 0, -1); ?>" layout="button_count" width="300" show_faces="false"></fb:like>


来源:https://stackoverflow.com/questions/6594319/facebook-like-button-not-working-on-recent-wordpress-blog-posts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!