简体   繁体   中英

Facebook sharing not working propely

I set parameters such as picture and name but it not displaying name of the pet and other information below is given a preview of sharing. why both previews are different and why not displaying some data please help me how can I resolve this error and thanks in advance.

Link - 1

https://www.facebook.com/dialog/feed?app_id=241670762980516&link=http://newseinstein.com/Rwork/index.php/Pet/view/105&picture=http://newseinstein.com/Rwork/uploads/405517413/img1.jpeg&name=scarpy/Airedale%20Terrier/Lost&caption=www.hero-pet.com&redirect_uri=https://www.facebook.com&display=popup

Link - 2

https://www.facebook.com/dialog/feed?app_id=241670762980516&link=http://newseinstein.com/Rwork/index.php/Pet/view/104&picture=http://newseinstein.com/Rwork/uploads/723253718/img1.jpeg&name=Please%20Help%20Me/Aegean%20cat/Found&caption=www.hero-pet.com&redirect_uri=https://www.facebook.com&display=popup

The best way is Instead of passing link directly in href tag Use some custom facebook developer jquery to share your post or page with the image.

For example, your a tag is like

<a id="fb_id" class="facebook" href="javascript:void(0);"><i class="fa fa-facebook" aria-hidden="true"></i></a>

and then you may use custom developer script like following,

window.fbAsyncInit = function() {
  FB.init({
    appId      : IP, // ADD YOUR appID
    xfbml      : true,
    version    : 'v2.5'
  });
};

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

window.onload = function(){
 document.getElementById('fb_id').onclick = function() {
  FB.ui({
    method: 'share', // YOU MAY SET YOUR METHOD HERE feed OR share
    href: DOMAIN, // ADD YOUR DOMAIN NAME HERE WHICH YOU HAVE ADDED WHILE CREATING NEW APP.
  }, function(response){});
};

};

It will sure display data with an image while sharing your page.

NOTE: IT MAY BE NOT WORK IN YOUR LOCAL ENVIRONMENT.

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