为什么我无法在 Facebook 上分享我的网页链接?
该代码对我来说看起来不错,但我不知道为什么它不打开 FB 弹出窗口并共享我的网站。
这是 js 部分
function streamPublish(name, description, hrefTitle, hrefLink, userPrompt){
FB.ui(
{
method: 'stream.publish',
message: '',
attachment: {
name: name,
caption: '',
description: (description),
href: hrefLink
},
action_links: [
{ text: hrefTitle, href: hrefLink }
],
user_prompt_message: userPrompt
},
function(response) {
});
}
function showStream(){
FB.api('/me', function(response) {
//console.log(response.id);
streamPublish(response.name, 'Connect with Abhishek Raj Simon on his new website http://abhisheksimion.cjb.net', 'hrefTitle', 'http://abhisheksimion.cjb.net', "Share abhisheksimion.cjb.net");
});
}
html
<a id="fbanchor" href="#" onclick="showStream(); return false;">Like it, Share it!</a>
有人能指出,我哪里出了问题吗?您可以访问正在进行的工作网站 http://abhisheksimion.cjb.net
The code looks fine to me, but I have no clue why is it not bringing up the FB popup and sharing my site.
here is the js part
function streamPublish(name, description, hrefTitle, hrefLink, userPrompt){
FB.ui(
{
method: 'stream.publish',
message: '',
attachment: {
name: name,
caption: '',
description: (description),
href: hrefLink
},
action_links: [
{ text: hrefTitle, href: hrefLink }
],
user_prompt_message: userPrompt
},
function(response) {
});
}
function showStream(){
FB.api('/me', function(response) {
//console.log(response.id);
streamPublish(response.name, 'Connect with Abhishek Raj Simon on his new website http://abhisheksimion.cjb.net', 'hrefTitle', 'http://abhisheksimion.cjb.net', "Share abhisheksimion.cjb.net");
});
}
html
<a id="fbanchor" href="#" onclick="showStream(); return false;">Like it, Share it!</a>
Can somebody point out, where am i going wrong? You can visit the work in progress website http://abhisheksimion.cjb.net
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我收到一个 JavaScript 错误:
我认为在您的脚本标记第 128 行中,右括号应该更高,以关闭
fqlQuery()
函数。如前所述,showStream()
是fqlQuery()
函数的一部分,这会导致showStream()
失败。如果您想做的只是添加基本的 Facebook 功能,例如“点赞”和“分享”,则无需使用大量 JavaScript 即可实现。
https://developers.facebook.com/docs/reference/plugins/like/
https://www.facebook.com/sharer/sharer.php?yoursite .com
其中“yoursite.com”是您要共享的网站。您可以使用 opengraph 标签来指定内容。
I get a javascript error:
I think in your script tag, line 128, that closing bracket should be higher, to close off the
fqlQuery()
function. As written,showStream()
is part of thefqlQuery()
function, which causesshowStream()
to fail.If all you are trying to do is add basic facebook functionality like "Like" and "Share" this can be achieved without using heavy javascript.
https://developers.facebook.com/docs/reference/plugins/like/
https://www.facebook.com/sharer/sharer.php?yoursite.com
Where 'yoursite.com' is the site you want to share. You can use opengraph tags to specify the content.