2013-08-16 94 views
1

我正在開發一個「share on facebook」按鈕。Titanium Facebook對話框不會出現

但是有一個問題,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(); 
    }); 
} 

函數正確調用,但沒有出現。

有人知道爲什麼嗎?也許權限?但我已經讀過,對話框不需要權限!

感謝所有

回答

0

我解決了我自己! 即使Facebook對話框不需要Auth(),它也需要具有AppID的init。

var fb = require('facebook'); 
fb.appid = your_app_id_number; 

有了這個工作得很好。

0

試試這個:

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();