[Facebook] 在不使用API Key 建立Facebook Share Button

正常情況下, 若網站需要執行Facebook功能如Like, Share, Login 等, 都須要在Facebook 登記一條API key, 並用它作相關設定. 然而, 在Share 功能中, 則有方法規避, Sample code 如下.

<script>
function fbShareTest()
{
	var fbpopup = window.open("https://www.facebook.com/sharer/sharer.php?u=https://www.chunho-ling.com", "pop", "width=600, height=400, scrollbars=no");
}
</script>
<button id="facebookShareLink" onclick="fbShareTest()">Share Test</button>
</script>

這方法最大的好處就是不須要複雜的JavaScript 便可實現, 但這功能曾被obsolated, 但於2014年又被enabled. 基於Facebook 過往的戰績, 還是自行決定這會否有問題了.

Reference

About C.H. Ling 262 Articles
a .net / Java developer from Hong Kong and currently located in United Kingdom. Thanks for Google because it solve many technical problems so I build this blog as return. Besides coding and trying advance technology, hiking and traveling is other favorite to me, so I will write down something what I see and what I feel during it. Happy reading!!!

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.