我正在使用发布的代码将内容发布到 Facebook 墙上。
FB.init({ appId: '我的应用程序 ID', 状态: true, cookie: true, xfbml: true, oauth: true })
$('#share_button').click(function (e) {
if ($('#textfield').val() != '发生了什么' && $('#textfield').val() != '') {
var lin = window.location.href;
FB.login(函数(响应){
如果(response.authResponse){
console.log("用户已连接到应用程序。");
var accessToken = response.authResponse.accessToken;
var fbURL = "https://graph.facebook.com/me/feed?access_token=" + accessToken;
$.ajax({
网址:fbURL,
数据: "message=" + $('#textfield').val() + "&picture=MyUrl/images/logo.png&name=FutureZoom&link=MyUrl",
类型:'POST',
成功:函数(resp){
$('#ValidationMessage').html('帖子已在您的墙上分享!')
.css('颜色', '绿色');
设置超时(函数(){
$('#ValidationMessage').html('');
}, 3000);
},
错误:功能(请求,状态,错误){
alert("Facebook 错误:\n" + request.responseText + '\n' + status + '\n' + error);
}
});
}
}, { 范围:'publish_stream' });
}
别的 {
$('#ValidationMessage').html('请写点东西分享!')
.addClass('red');
}
});
以上在 Firefox 浏览器中运行良好,但问题在于 IE 和 Chrome。在 Chrome 中,上面的代码将评论发布在墙上,但是当返回时,它进入错误块而不是成功。以下是进入 chrome 的错误。
Facebook Error:
{
"id": "100002506055900_30229318964214"
}
parseerror
SyntaxError: Unexpected token:
而在 IE 中,什么也没有发生。既不发布评论也不返回错误/成功块。
可能是什么原因?