且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Facebook分享按钮的自定义图像

更新时间:2023-12-04 22:59:34

此代码对我有用:

<!-- facebook -->
<img src="[YOUR_FACEBOOK_PIC]" alt="Share on Facebook" onclick="window.open('https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent('[YOUR_PAGE_URL]'),'facebook-share-dialog','width=626,height=436'); return false;">

<!-- twitter -->
<img src="[YOUR_TWITTER_PIC]" alt="Share on Twitter" onclick="javascript:window.open('https://twitter.com/share?text=[SOME_TEXT_TO_PREPOLUTATE_TWEET]&amp;url=[YOUR_PAGE_URL]','Twitter-dialog','width=626,height=436'); return false;">

<!-- google+ -->
<img src="[YOUR_GOOGLE_PIC]" alt="Share on Google Plus" onclick="window.open('https://plus.google.com/share?url=[YOUR_PAGE_URL]','Google-dialog','width=626,height=436'); return false;">

只需替换括号之间的文字,不要忘记url编码所有文本进入url以避免问题。

Just replace the text between brackets, and don't forget to "url encode" all the text that goes in the url to avoid issues.

它不需要任何SDK的SDK。

And it doesn't need the SDK for any of them.

以下是每个参考官方文档:

Here are references to the official documentation for each of them:

  • Facebook (you can see it under the URL redirection section)
  • Twitter (you could also use https://twitter.com/intent/tweet as described here)
  • Google+ (under Share Link section)