facebook分享(含圖片)
來(lái)源:程序員人生 發(fā)布時(shí)間:2015-04-17 08:49:36 閱讀次數(shù):3381次
1、查看當(dāng)前URL下facebook信息情況
Open Graph Object Debugger<輸入U(xiǎn)RL,查看當(dāng)前URL是不是具有facebook信息>:
https://developers.facebook.com/tools/debug/og/object/
Show existing scrape information:查看已配置的facebook信息
Fetch new scrape information:設(shè)置新的facebook信息
2、設(shè)置對(duì)應(yīng)facebook信息
1. 所有信息必須在對(duì)應(yīng)URL下的頁(yè)面進(jìn)行添加,如www.baidu.com,必須在baidu的主頁(yè)下進(jìn)行添加
2. Facebook同享清單,參照下述URL
https://developers.facebook.com/docs/plugins/checklist
3、實(shí)例
如:在http://tztest4.ptmind.cn/test.htm下,添加facebook分享代碼。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF⑻">
<title>facebook share test</title>
<meta property="og:site_name" content="site name"/>
<meta property="og:title" content="title"/>
<meta property="og:type" content="website"/>
<meta property="og:description" content="description"/>
<meta property="og:image" content="http://www.ptengine.jp/images/hatenablog.png"/>
<meta property="og:url" content="http://tztest4.ptmind.cn/test.htm">
</head>
<body>
<script>
function fbs_click(){
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent('http://tztest4.ptmind.cn/test.htm'),'sharer','toolbar=0,status=0,width=626,height=436');
return false;
}
</script>
<a onclick="return fbs_click()" target="_blank">
<img src="ADD_IMAGE_URL_HERE" alt="Share on Facebook" />
</a>
</body>
</html>
Window.open()請(qǐng)參考:http://www.w3cschool.cc/jsref/met-win-open.html
facebook開發(fā)API:https://developers.facebook.com/docs/plugins/embedded-posts
分享按鈕:https://developers.facebook.com/docs/plugins/share-button/
參考文獻(xiàn):http://blog.sina.com.cn/s/blog_6cd33db60100sd9j.html
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)