简体   繁体   中英

Passing custom text to new Facebook Sharer button

I need to pass some AngularJS variables from my application to the new Facebook sharer button, I'm using:

<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/es_LA/all.js#xfbml=1&appId=1438439249728371";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

And this:

 <div class="fb-share-button" data-href="http://mySite" data-type="button">     </div>

Where can I place my custom text to share in the dialog?

Thank you!

Sharer wont allow that. It'll fetch the og tags from the link and fill the contents in the dialog.

If you want to add cutomized description/picture/caption you should instead use Feed Dialog .

You can use the direct URL to invoke feed dialog:

https://www.facebook.com/dialog/feed?
 app_id=1438439249728371
 &display=popup
 &caption={caption}
 &link={link-to-share}
 &description={description}
 &redirect_uri={redirect-url-to-your-site}

You can check all available parameters here

If you use the Facebook SDK for JavaScript you have to use the parameter quote

  FB.ui({
    method: 'share',
    display: 'popup',
    href: window.location.href,
    quote: "Your Custom Text"
  }, function(response){});

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