我正在开发一个"在facebook上共享"按钮。
但有一个问题,脸书对话框没有提示给用户。
我试过钛提供的样品:
function facebook(){
var fb = require('facebook');
var data = {
link : "http://www.appcelerator.com",
name : "Appcelerator Titanium Mobile",
message : "Checkout this cool open source project for creating apps",
caption : "Appcelerator Titanium Mobile",
picture : "http://developer.appcelerator.com/assets/img/DEV_titmobile_image.png",
description : "You've got the ideas, now you've got the power."
};
fb.dialog("feed", data, function(e) {
var toast = Ti.UI.createNotification({
message:"Default",
duration: Ti.UI.NOTIFICATION_DURATION_LONG
});
if(e.success && e.result)
toast.message = "Success! New Post ID: " + e.result;
else {
if(e.error)
toast.message = e.error;
else
toast.message = "User canceled dialog.";
}
toast.show();
});
}
函数调用正确,但没有显示任何内容。
有人知道为什么?也许是权限?但是我已经读到了,对于对话框不需要权限!
感谢所有
试试这个:
var fb = require('facebook');
fb.appid = FACEBOOK_APP_ID;
fb.permissions = ['publish_stream']; // Permissions your app needs
fb.forceDialogAuth = true;
fb.addEventListener('login', function(e) {
if (e.success) {
alert('Logged In');
} else if (e.error) {
alert(e.error);
} else if (e.cancelled) {
alert("Canceled");
}
});
fb.authorize();
我自己解决了!即使Facebook对话框不需要Auth(),它也需要带有AppID的init。
var fb = require('facebook');
fb.appid = your_app_id_number;
这样做效果很好。