Header Ads

ad

Nút Thích cho web


Một lần nhấp vào nút Thích sẽ 'thích' đoạn nội dung trên web và chia sẻ nội dung đó trên Facebook. Bạn cũng có thể hiển thị nút Chia sẻ bên cạnh nút Thích để cho phép mọi người thêm tin nhắn cá nhân và tùy chỉnh người mà họ chia sẻ cùng.


Từng bước

1. Chọn URL hoặc Trang

Chọn URL của trang web hoặc Trang Facebook mà bạn muốn sử dụng với nút thích.

2. Bộ cấu hình mã

Dán URL vào bộ cấu hình mã và điều chỉnh các cài đặt như width của nút thích. Nhấp vào nút Get Codeđể tạo mã nút thích.

3. Sao chép & dán đoạn mã HTML

Sao chép và dán đoạn mã vào HTML của trang web đích.

Mẫu mã đầy đủ

Sao chép & dán mẫu mã vào trang web của bạn. Điều chỉnh giá trị data-href cho URL của trang web. Tiếp theo, sử dụng thẻ meta og:*** để điều chỉnh bản xem trước liên kết của bạn. og:url và data-hrefphải sử dụng cùng một URL.
<html>
<head>
  <title>Your Website Title</title>
    <!-- You can use open graph tags to customize link previews.
    Learn more: https://developers.facebook.com/docs/sharing/webmasters -->
  <meta property="og:url"           content="http://www.your-domain.com/your-page.html" />
  <meta property="og:type"          content="website" />
  <meta property="og:title"         content="Your Website Title" />
  <meta property="og:description"   content="Your description" />
  <meta property="og:image"         content="http://www.your-domain.com/path/image.jpg" />
</head>
<body>

  <!-- Load Facebook SDK for JavaScript -->
  <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/en_US/sdk.js#xfbml=1";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));</script>

  <!-- Your like button code -->
  <div class="fb-like" 
    data-href="http://www.your-domain.com/your-page.html" 
    data-layout="standard" 
    data-action="like" 
    data-show-faces="true">
  </div></body></html>
Xem thêm :
https://developers.facebook.com/docs/plugins/like-button

No comments