How to Add the Facebook Comments Plugin to Your Website — Full Guide + Code


Programming How to Add the Facebook Comments Plugin to Your Website — Full Guide + Code

07 Aug 2024 11:15 782 reads

 

การใช้งาน Facebook Comments Plugin บนเว็บไซต์ของคุณเป็นวิธีที่ยอดเยี่ยมในการเพิ่มการมีส่วนร่วมของผู้ใช้ และช่วยให้พวกเขาสามารถแสดงความคิดเห็นและแชร์คอนเทนต์ได้อย่างง่ายดาย โดยเราจะใช้ Social Plugin ของ Facebook ที่เตรียมไว้ให้ใช้ให้เลยมากมาย ไม่ว่าจะเป็นการแสดงความคิดเห็น กดไลท์ กดแชร์ เป็นต้น

 

 

ขั้นตอนการติดตั้ง Facebook Comments Plugin

 

 

 

1. เตรียม Facebook App ID

 

 

 

หากคุณยังไม่มี Facebook App ID คุณต้องสร้างแอปใน Facebook Developer เพื่อรับ App ID


 

 

  • ให้เข้าไปที่ Facebook for Developers
  • ล็อกอินด้วยบัญชี Facebook
  • คลิกที่ My Apps ที่มุมบนขวา แล้วเลือก Create App ขึ้นมาใหม่
  • เลือกประเภทแอปที่เหมาะสม และทำตามขั้นตอนเพื่อสร้างแอปใหม่ หลังจากสร้างเสร็จ และเราจะได้รับ App ID

 

 

2. การสร้างโค้ดสำหรับ Comments Plugin


 

 

ให้เข้าไปที่ https://developers.facebook.com/docs/plugins/

 

 

จะเห็นว่า Social Plugins ของ Facebook ที่เตรียมให้จะมีให้เลือกใช้มากมาย เช่น ปุ่มกดไลท์ ปุ่มกดแชร์ บล็อคแสดงความคิดเห็น ในวันนี้เราจะมาสาธิตวิธีการใช้ Comment Plugin กันครับ

 

 

กรอกข้อมูล URL ของหน้าเว็บที่ต้องการให้มีการแสดงความคิดเห็น เราสามารถกำหนดความกว้าง และจำนวนโพสต์ที่ต้องการแสดงได้ จากนั้นกดปุ่ม Get code เพื่อรับโค้ด

 

กำหนดค่าปลั๊กอิน
  • URL of the object: กรอก URL ของหน้าเว็บที่คุณต้องการให้แสดงความคิดเห็น
  • Width: กำหนดความกว้างของช่องแสดงความคิดเห็น (เป็น pixel)
  • Number of posts: กำหนดจำนวนความคิดเห็นที่ต้องการแสดง
  • Options: เลือกตั้งค่าเพิ่มเติม เช่น การแสดงปุ่ม Like, ส่งข้อความ หรือแสดงความคิดเห็นในรูปแบบต่าง ๆ

นำไปวางบนหน้าเว็บไซต์ที่เราต้องการแสดง


 

 

หลังจากนำโค้ดที่ได้รับ ไปวางบนเว็บไซต์ในจุดที่ต้องการเรียบร้อยแล้วผลลัพธ์ของกล่องข้อความแสดงความคิดเห็นก็จะปรากฎตามรูปนี้เลยครับ

แก้ปัญหากล่องแสดงความคิดเห็นของ Facbook ไม่ขยายตามขนาดของ Layout ที่อยู่ 100% ให้ใส่ data-width="100%" ลงใน Tag ของ

  
 

และเพิ่มโค้ด Style เพื่อกำหนดขนาดของความกว้างให้เป็น 100% เพื่อแก้ไขปัญหานี้




Please rate your satisfaction with this article

Star 1 Star 2 Star 3 Star 4 Star 5

Post a Comment
Your email address will not be displayed to others. Required fields are marked *

CAPTCHA





Recommended Content

What Is Cursor AI? The Intelligent Code Editor That Combines AI Power with VS Code
(02/11/2025 12:45)
Cursor AI is an AI-powered code editor built on top of Visual Studio Code (VS Code). It offers a familiar, flexible int…
Read more
How to reset your iPhone when it is locked with the message
(01/02/2025 12:00)
If your iPhone shows the message "iPhone Unavailable" and you can’t unlock it, you’ll need to perform a Factory Reset a…
Read more
Export HTML Table to Excel with TableExport (No jQuery) — Copy-Ready Code
(15/08/2024 18:00)
In the previous article, we introduced how to import data from an Excel file using the phpoffice/phpspreadsheet library…
Read more
What is og : Open Graph, and what is its significance in SEO for Facebook and social media?
(07/08/2024 11:15)
Open Graph is a protocol developed by Facebook that is used to connect websites with social media platforms through the…
Read more
Import Excel to PHP with phpoffice/phpspreadsheet – Step-by-Step Guide with Code
(06/08/2024 10:00)
phpoffice/phpspreadsheet is a popular PHP library used for working with Excel files, including creating new files, read…
Read more
How to Create and Submit a Sitemap to Google Search Console – Improve SEO Visibility
(05/08/2024 09:30)
What is a Google Search Console Sitemap? A Google Search Console Sitemap, or simply a sitemap, is like a map you create…
Read more
How to Send LINE Notify Alerts with MQL5 – Step-by-Step Guide
(06/07/2024 08:30)
What is MQL5? MQL5 (MetaQuotes Language 5) is a programming language developed by MetaQuotes Software Corp. for writing…
Read more
Learn MQL5 Programming – Beginner’s Guide to Automated Trading in MetaTrader 5
(20/06/2024 17:30)
MQL5 (MetaQuotes Language 5) is a programming language developed by MetaQuotes Software Corp. for writing automated tra…
Read more