简体   繁体   English

如何使用Facebook,LinkedIn和Twitter共享按钮共享当前页面?

[英]How to share the current page with the Facebook,LinkedIn and Twitter Share Button?

I'm sorry if this question has already been asked but this case is different. 很抱歉,如果您已经提出此问题,但情况有所不同。 I'm trying to make a Facebook button that is sharing the current URL but I have no idea how to do this.My question is : What should I put instead of 'homepage' so that these buttons share the page the user is currently on instead of a specific URL ? 我正在尝试制作一个共享当前URL的Facebook按钮,但我不知道该怎么做。我的问题是:我应该放置什么而不是``主页'',以便这些按钮共享用户当前所在的页面而不是特定的URL? Here's what the current code looks like (I replaced the website's URL by homepage) : 这是当前代码的样子(我用首页替换了网站的URL):

  <a href="http://www.facebook.com/sharer.php?u='homepage' target="_blank" style="text-decoration:none">
    <img src="http://image.noelshack.com/fichiers/2015/25/1434621881-iconmonstr-facebook-4-icon-32.png" alt="Facebook">
</a>

<!-- LinkedIn -->
<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=homepage" target="_blank" style="text-decoration:none">
    <img src="http://image.noelshack.com/fichiers/2015/25/1434621881-iconmonstr-linkedin-4-icon-32.png" alt="LinkedIn">
</a>

<!-- Twitter -->
<a href="https://twitter.com/share?url=homepage" target="_blank" style="text-decoration:none">
    <img src="http://image.noelshack.com/fichiers/2015/25/1434621881-iconmonstr-twitter-4-icon-32.png" alt="Twitter">
</a>
// Get the current URL
<?php
$Url = (@$_SERVER["HTTPS"] == "on") ? "https://" : "http://";
$Url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
?>
<a href="http://www.facebook.com/sharer.php?u=<?php echo $Url; ?>" target="_blank" style="text-decoration:none">
    <img src="http://image.noelshack.com/fichiers/2015/25/1434621881-iconmonstr-facebook-4-icon-32.png" alt="Facebook">
</a>

<!-- LinkedIn -->
<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=<?php echo $Url; ?>" target="_blank" style="text-decoration:none">
    <img src="http://image.noelshack.com/fichiers/2015/25/1434621881-iconmonstr-linkedin-4-icon-32.png" alt="LinkedIn">
</a>

<!-- Twitter -->
<a href="https://twitter.com/share?url=<?php echo $Url; ?>" target="_blank" style="text-decoration:none">
    <img src="http://image.noelshack.com/fichiers/2015/25/1434621881-iconmonstr-twitter-4-icon-32.png" alt="Twitter">
</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM