-3

我在Unity工作。Facebook的帖子不能與Facebook中的應用程序一起工作在設備中

我試圖使用Facebook SDK插件將分數發佈到Facebook牆上。

雖然我在安裝了官方Facebook應用程序的情況下使用了一個設備(Nexus7,MotoG),但FB.Feed()方法不起作用,並且設備中沒有出現對話框。

我試過Facebook Unity SDK on Android - Login fails when FB App installed的解決方案,但它不適用於我。

這裏是我的fblogin腳本:

public class fblogin : MonoBehaviour 
{ 

     private string status = "Ready"; 
     private string lastResponse = ""; 
     public GUIStyle textStyle = new GUIStyle(); 
     private Texture2D lastResponseTexture; 
     private bool isInit = false; 

     // Use this for initialization 
     void Start() 
     { 

     } 

     // Update is called once per frame 
     void Update() 
     { 

     } 

     void OnGUI() 
     { 

       if (GUI.Button (new Rect (10, 10, 300, 100), "FB.Init")) { 
         CallFBInit(); 
         status = "FB.Init() called with " + FB.AppId; 

       } 

       if (GUI.Button (new Rect (100, 100, 300, 100), "Login")) { 
         //FB.Init (OnInitComplete, OnHideUnity); 
         //status = "FB.Init() called with " + FB.AppId; 
         CallFBLogin(); 
       } 

       if (GUI.Button (new Rect (200, 200, 300, 100), "Share")) { 
         //FB.Init (OnInitComplete, OnHideUnity); 
         //status = "FB.Init() called with " + FB.AppId; 
         onBragClicked();  
       } 





     } 

     private void onBragClicked() 
     {                                
       //Util.Log ("onBragClicked");                        
       FB.Feed (
       linkCaption: "I just smashed " + "15" + " friends! Can you beat it?",    
       picture: "http://www.friendsmash.com/images/logo_large.jpg",              
       linkName: "Checkout my Friend Smash greatness!",                 
       link: "http://apps.facebook.com/" + FB.AppId + "/?challenge_brag=" + (FB.IsLoggedIn ? FB.UserId : "guest")  
       );                            
     } 

     private void CallFBInit() 
     { 
       FB.Init (OnInitComplete, OnHideUnity); 
     } 

     private void OnInitComplete() 
     { 
       Debug.Log ("FB.Init completed: Is user logged in? " + FB.IsLoggedIn); 
       isInit = true; 
     } 

     private void OnHideUnity (bool isGameShown) 
     { 
       Debug.Log ("Is game showing? " + isGameShown); 
     } 

     private void CallFBLogin() 
     { 
       FB.Login ("email,publish_actions", LoginCallback); 
     } 

     void LoginCallback (FBResult result) 
     { 
       if (result.Error != null) 
         lastResponse = "Error Response:\n" + result.Error; 
       else if (!FB.IsLoggedIn) { 
         lastResponse = "Login cancelled by Player"; 
       } else { 
         lastResponse = "Login was successful!"; 
       } 
     } 
     } 

誰能幫助?

+0

你能夠登錄嗎? – JRowan

+0

是的,如果我已經註銷登錄框出現併成功登錄,但...飼料對話框不會出現.... –

+0

把它放在你的腳本,並呼籲CallFBFeed(),當你想飼料提出,但首先填寫你想要的檢查員 – JRowan

回答

1

把這個放在你的腳本里面,並在檢查器中填寫所有的FeedParameters,我想這是因爲你沒有在Feed中指定回調,而是把它放在你的腳本中並在檢查器中填入參數,其中一些需要的場所,否則飼料將不會出現

#region FB.Feed() example 

    public string FeedToId = ""; 
    public string FeedLink = ""; 
    public string FeedLinkName = ""; 
    public string FeedLinkCaption = ""; 
    public string FeedLinkDescription = ""; 
    public string FeedPicture = ""; 
    public string FeedMediaSource = ""; 
    public string FeedActionName = ""; 
    public string FeedActionLink = ""; 
    public string FeedReference = ""; 
    public bool IncludeFeedProperties = false; 
    private Dictionary<string, string[]> FeedProperties = new Dictionary<string, string[]>(); 

    void Callback(FBResult result) 
    { 
     //lastResponseTexture = null; 
     // Some platforms return the empty string instead of null. 
     //if (!String.IsNullOrEmpty(result.Error)){ 
      //lastResponse = "Error Response:\n" + result.Error; 
     //} 
     //else if (!ApiQuery.Contains("/picture")){ 
      //lastResponse = "Success Response:\n" + result.Text; 
     //} 
     //else 
     //{ 
      //lastResponseTexture = result.Texture; 
      //lastResponse = "Success Response:\n"; 
     //} 
    } 

    private void CallFBFeed() 
    { 
     Dictionary<string, string[]> feedProperties = null; 
     if (IncludeFeedProperties) 
     { 
      feedProperties = FeedProperties; 
     } 
     FB.Feed(
      toId: FeedToId, 
      link: FeedLink, 
      linkName: FeedLinkName, 
      linkCaption: FeedLinkCaption, 
      linkDescription: FeedLinkDescription, 
      picture: FeedPicture, 
      mediaSource: FeedMediaSource, 
      actionName: FeedActionName, 
      actionLink: FeedActionLink, 
      reference: FeedReference, 
      properties: feedProperties, 
      callback: Callback 
      ); 
    } 

    #endregion 
+1

好吧,這是正確的... ...但如果我嘗試卸載facebook應用程序,而不是之後,它成功張貼在fb牆上。 –

+0

idk告訴你什麼,你有它的工作? – JRowan

+0

idk的意思.. ???我不知道idk。 –

相關問題