簡單就能讓網站擁有按讚功能

facebook og meta setting 2018-10-30 23:22:22
javascript

Facebook的按讚分享功能配置起來真的很簡單

設定好 og meta,放置要顯示fb like share的div,最後加上js的部分就好了

 

Step1 Set og meta tag

<meta property="og:url"           content="{{ url()->current() }}" />
<meta property="og:type"          content="article" />
<meta property="og:title"         content="{{ $blog->title }}" />
<meta property="og:description"   content="{{ $blog->subtitle }}" />
<meta property="og:image"         content="{{ $blog->image }}" />

 

 

Step2 add fb-like div

<div class="fb-like" 
        data-href="{{ url()->current() }}" 
        data-layout="standard" 
        data-action="like" 
        data-size="small" 
        data-show-faces="true" 
        data-share="true"></div>

 

 

Step3 Javascript

<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 = 'https://connect.facebook.net/zh_TW/sdk.js#xfbml=1&version=v3.2';
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

參考 : https://developers.facebook.com/docs/plugins/like-button?locale=zh_TW#


FB 留言
  • 頭香!
    writing dissertation service http://essay2y.com/ write papers online Nyktna aqwgxl
    By Otfzsq 2021/01/28 23:55
  • 2 樓
    http://bio-catalyst.com/ - buy cephalexin online myambutol generic floxin price buy zyvox generic
    By JamesExela 2021/02/16 14:55