简体   繁体   English

使用JavaScript在Facebook上分享

[英]Share on Facebook using JavaScript

I'm trying to build a customized share button for Facebook using the script sharer.php with something like this: 我正在尝试使用脚本sharer.php为Facebook构建一个自定义的共享按钮,如下所示:

<html>
<head>
<script type="text/javascript">
window.onload = function () {
    var button = document.getElementById("share");

    button.onclick = function() {
        var title = encodeURIComponent('My title');
        var summary = encodeURIComponent('My message');
        var url = encodeURIComponent('https://www.mysite.com/foo');
        var image = encodeURIComponent('https://pics.mysite.com/mylogo.png');

        window.open('http://www.facebook.com/sharer.php?s=100&amp;p[title]=' + title + '&amp;p[summary]=' + summary + '&amp;p[url]=' + url + '&amp;p[images][0]=' + image,'sharer','toolbar=0,status=0,width=548,height=325');
    }
}
</script>
</head>
<body>
<input type="button" id="share" value="Share" />
</body>
</html>

When I click the button, the Facebook login and share windows open, but the share window only shows a warning about "some people not being able to see the post because of its privacy settings". 当我单击该按钮时,Facebook登录和共享窗口将打开,但是共享窗口仅显示有关“某些人由于其隐私设置而无法看到该帖子”的警告。 I verified that there is nothing wrong with those settings. 我确认这些设置没有问题。 However, when I eventually try to share I get the error "The message could not be posted to this Wall". 但是,当我最终尝试共享时,出现错误“消息无法发布到此墙”。

What am I doing wrong? 我究竟做错了什么?

Turns out there is nothing wrong with this approach. 事实证明,这种方法没有错。 After upgrading from node.js/express 2 to express 3 everything works just fine. 从node.js / express 2升级到Express 3后,一切正常。

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

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