【发布时间】:2016-08-12 07:21:41
【问题描述】:
我的编码如下:
<!DOCTYPE>
<html>
<head>
<script src="https://connect.facebook.net/en_US/sdk.js"></script>
<meta property="fb:app_id" content="1665615247095212" />
<meta property="og:type" content="heppiheppi:shares" />
<meta property="og:url" content="http://mywebsite.com" />
<meta property="og:title" content="Walk-in" />
<meta property="og:image" content="http://mywebsite.com/images/intro.jpg" />
<meta property="og:description" content="Bring more customers" />
</head>
<body style='padding:0;margin:0;'>
<div id="fb-root"></div>
<script>
FB.init({
appId : '1665615247095212',
xfbml : true,
version : 'v2.7'
});
function LaunchDialog(){
FB.ui({
method: 'share_open_graph',
action_type: 'og.shares',
action_properties: JSON.stringify({
object:'http://mywebsite.com',
})
},
function(response) {
if (response && !response.error_message) {
alert('Posting completed.');
} else {
alert('Error while posting.');
}
});
}
</script>
<a href="#" onclick="LaunchDialog();">Share now</a>
</body>
</html>
如果在桌面浏览器上测试,点击“立即分享”,弹出分享对话框,点击取消/X,会显示“发帖时出错”。 如果在手机浏览器上测试,点击“立即分享”,弹出分享对话框,点击取消/X,会显示“发布完成”。 有人对这个问题有任何线索吗?
【问题讨论】:
-
检查响应对象实际包含的内容。
-
我可以知道如何检查吗?
-
我使用 console.log 来检查响应对象。如果在桌面浏览器上测试,点击 Post to Facebook,它不会显示任何内容;单击取消/X,它将显示“未定义”。
-
您是否在移动设备上登录了 Facebook? (在浏览器中,不是任何本机应用程序。)
标签: javascript facebook fb.ui share-open-graph