您的位置:首页 > 移动开发

关于把文章分享到facebook,google,twtter,whatsapp的总结

2018-03-01 20:35 344 查看
关于把文章分享到facebook,google,twtter,whatsapp的总结在网站的mete标签处还需要添加内容<!-- twitter share--> <meta name="title" content="lopScoop"> <meta name="twitter:site" content="@lopscoopNews"> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:url" class="share_url" content="http://hotintoday.com/content?id=${contentInfo.id}"> <meta name="twitter:title" class="share_title" content="${contentInfo.title }"> <meta name="twitter:description" content="${contentInfo.description }"> <meta name="twitter:image" content="${contentInfo.thumbnail}"> <!-- FaceBook share-->以及<!-- google+ share --> <meta property="og:url" class="share_url" content="http://hotintoday.com/content?id=${contentInfo.id}" /> <meta property="og:type" content="article" /> <meta property="og:title" class="share_title" content="${contentInfo.title }" /> <meta property="og:description" content="${contentInfo.description}" /> <meta property="og:image" content="${contentInfo.thumbnail }" /> <meta property="fb:app_id" content="1873127332917427" /> //facebook需要appid获取//分享到facebookfunction fbShare(contentId) { u = document.getElementsByClassName("share_url")[0].content; t = document.getElementsByClassName("share_title")[0].content; if (contentId == "-1") { contentId = $("#sharedContendId").html(); } window.open("http://www.facebook.com/sharer.php?u="+ encodeURIComponent(u) + "&t="+ encodeURIComponent(t), "sharer","toolbar=0,status=0,width=626,height=436");}//分享到googlefunction googleShare(contentId) { u = document.getElementsByClassName("share_url")[0].content; t = document.getElementsByClassName("share_title")[0].content; if (contentId == "-1") { contentId = $("#sharedContendId").html(); } //window.open("https://plus.google.com/share?url="+ encodeURIComponent(u), "sharer","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600");}//分享到twtterfunction twitterShare(contentId) { u = document.getElementsByClassName("share_url")[0].content; t = document.getElementsByClassName("share_title")[0].content; if (contentId == "-1") { contentId = $("#sharedContendId").html(); } //window.open("http://twitter.com/home?status="+ encodeURIComponent(u) + " " + encodeURIComponent(t),"sharer", "toolbar=0,status=0,width=626,height=436");}分享到whatsappfunction whatsApp(contentId){ u = document.getElementsByClassName("share_url")[0].content; t = document.getElementsByClassName("share_title")[0].content; if (contentId == "-1") { contentId = $("#sharedContendId").html(); } location="whatsapp://send?text="+ encodeURIComponent(t) + encodeURIComponent("\n\n"+u)+"&via=lopscoop";}
//1 facebook 2 pinterest 3 email 4 twitter 5 tumblr//6 relop 7 reddit 8 stumbleupon 9 google 10 linkedin 11 gettile 复制网址',12 whatsapp页面调用的方法(html)<div class="xq-loginshare"> <a href="javascript:fbShare();" class="xq-facebook">facebook</a> <a href="javascript:googleShare();" class="xq-google">google</a> <a href="javascript:twitterShare();" class="xq-twtter">twtter</a> <a href="javascript:whatsApp();" class="xq-whatsapp" data-action="share/whatsapp/share">whatsApp</a> </div>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息