简体   繁体   中英

Facebook custom share button not showing description

I am using following JS code for sharing on facebook.

function openFbPopUp() {
    var fburl = 'http://54.251.121.6/cnc/cupcakes-n-chai-side-table';
    var fbimgurl = 'http://imageURL';
    var fbtitle = 'Your title';
    var fbsummary = "This is the description blah blah blah";
    var sharerURL = "http://www.facebook.com/sharer/sharer.php?s=100&p[url]=" + encodeURI(fburl) + "&p[images][0]=" + encodeURI(fbimgurl) + "&p[title]=" + encodeURI(fbtitle) + "&p[summary]=" + encodeURI(fbsummary);
    window.open(
      sharerURL,
      'facebook-share-dialog', 
      'width=626,height=436'); 
    return  false;
}

In the pop-up window, the Description text seems fine. But when seen in facebook, the description does not show up

While sharing, Description(summary text) can be seen. 说明可见

But Description(summary text) not showing in facebook.

说明未显示

On whatever page you're sharing, try putting the following:

<meta property="fb:app_id" content="{Your_App_ID}"/>
<meta property="og:url" content="http://54.251.121.6/cnc/cupcakes-n-chai-side-table"/>
<meta property="og:title" content="Your title"/>
<meta property="og:image" content="http://imageURL"/>
<meta property="og:description" content="This is the description blah blah blah">

However, if you're already using JS, how about using the Facebook JS SDK?

Just put the following code right after your tag:

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '{your-app-id}',
      status     : true,
      xfbml      : true
    });
  };

  (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";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));
</script>

Then, to invoke the share dialog, just call the following:

FB.ui({
        method: 'feed',
        name: 'Your title',
        link: 'http://54.251.121.6/cnc/cupcakes-n-chai-side-table',
        picture: 'http://imageURL',
        caption: '',
        description: 'This is the description blah blah blah',
        ref: '{your_reference_call_here}'
});

My personal experience suggests using the JS SDK to share things is much safer (ensures no bugs) than using the URL Redirection method.

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