我需要在FBML应用程序中使用FBJS向当前用户的墙发布一些消息。 当我使用
window.fbAsyncInit = function() {
FB.init({appId: 'MY_APP_ID', status: true, cookie: true, xfbml: false});
};
我收到错误: - FB未定义。 和 窗口未定义。 对于发布我正在使用此代码
function graphStreamPublish(){
var body = document.getElementById("txtTextToPublish").value;
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
// alert('Error occured');
} else {
// alert('Post ID: ' + response.id);
}
});
}
(我不能在facebook上使用警报..)
提前致谢..
答案 0 :(得分:1)
如果你正在使用FBML,你应该使用FBJS而不是Facebook Connect API。
var body = document.getElementById('txtTextToPublish').getValue();
Facebook.streamPublish(body);
由于使用FBJS,请注意getValue()调用而不是.value。