Creating a Facebook share button with customized url, title and image

前端 未结 4 1780

Facebook used to allow custom parameters in the Facebook share button, but it is not working now. What I need is to create a Facebook share button which will have a custom t

相关标签:
4条回答
  • 2020-12-30 09:27

    Crude, but it works on our system:

    <div class="block-share spread-share p-t-md">
      <a href="http://www.facebook.com/share.php?u=http://www.voteleavetakecontrol.org/our_affiliates&title=Farmers+for+Britain+have+made+the+sensible+decision+to+Vote+Leave.+Be+part+of+a+better+future+for+us+all.+Please+share!" 
         target="_blank">
        <button class="btn btn-social btn-facebook">
          <span class="icon icon-facebook">
          </span> 
          Share on Facebook
        </button>
      </a>
    
      <a href="https://www.facebook.com/FarmersForBritain" target="_blank">
        <button class="btn btn-social btn-facebook">
          <span class="icon icon-facebook">
          </span>
          Like  on Facebook
        </button>
      </a>
    </div>
    
    0 讨论(0)
  • 2020-12-30 09:30

    Unfortunately, it appears that we can't post shares for individual topics or articles within a page. It appears Facebook just wants us to share entire pages (based on url only).

    There's also their new share dialog, but even though they claim it can do all of what the old sharer.php could do, that doesn't appear to be true.

    And here's Facebooks 'best practices' for sharing.

    0 讨论(0)
  • 2020-12-30 09:33

    This is the code as 2017:

    <i class="fa fa-facebook-square"></i>
    <a href="#" onclick="window.open('https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href),'facebook-share-dialog','width=626,height=436');return false;">Share on Facebook</a>
    

    Facebook now takes all data from OG metatags.

    NOTE: This code assumes you have OG metatags on in site's code.

    Source

    0 讨论(0)
  • 2020-12-30 09:37

    Use facebook feed dialog instead of share dialog.

    Example:

    https://www.facebook.com/dialog/feed?app_id=1389892087910588 &redirect_uri=https://scotch.io &link=https://scotch.io &picture=http://placekitten.com/500/500 &caption=This%20is%20the%20caption &description=This%20is%20the%20description

    0 讨论(0)
提交回复
热议问题