简体   繁体   中英

Last Script for Like Button is not Posting in the Wall

I'm using the lastest script in facebook developers page but when the like button is clicked, the article is not being posted on the facebook wall.

The web page with the issue is http://www.captap.com/blog . The code I'm using is below

After body tag

<div id="fb-root"></div>

<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));</script> 

Button Code:

<div class="fb-like" data-href="https://www.captap.com/blog/{categories limit='1'}{category_url_title}{/categories}/{url_title}" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div>

I have been running into the same issue.. Your code looks correct, however there are 2 things that could be influencing the URL that is being liked.

  1. If you have any OpenGraph tags that specify the URL, Facebook will use that URL over the href tag on the like button code.

     <meta property="og:url" content="https://www.captap.com/blog" /> 
  2. If you have a canonical link in the header, Facebook can also prefer this URL over the href tag on your like button code.

     <link rel="canonical" href="https://www.captap.com/blog" /> 

For either one of these options, your choices are to either remove that link in the header, or update the link to match the permalink for the blog post you are trying to like. If your like button is located on the post page itself, then updating the link will work. However if your like button is on a page with multiple posts your best bet would be to remove that link in the header so it is not overwriting the href you have included in your like button code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM