2014-05-20 12 views
0

페이스 북에 연결하는 Android 게임을 개발 중입니다. 사용자가 연결되어 있으면 Facebook 벽에 응용 프로그램을 게시 할 수 있습니다.Facebook SDK Unity Publish

스크립트의 문제점 InteractiveConsole.cs 사용자가 게시 버튼을 클릭 한 다음 취소 버튼을 클릭하면 "게시되지 않았습니다."라는 메시지가 표시됩니다. 게시 버튼 만 클릭하고 게시 할 때 "게시"메시지를 표시하려고합니다.

문제는 두 경우 모두 게시 또는 취소하기로 결정할 때 GUI에 "게시"메시지가 표시된다는 것입니다.

페이스 북 공유하기 취소
public GUIText guiFeed; 

#region FB.Feed() example 

    public string FeedToId = ""; 
    public string FeedLink = "http://www.google.com"; 
    public string FeedLinkName = "Test"; 
    public string FeedLinkCaption = "Test Caption "; 
    public string FeedLinkDescription = "Test Deszcription"; 
    public string FeedPicture = "http://www.selfspark.com/wp-content/uploads/Smiley-Face-Button.jpg"; 
    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[]>(); 

    public 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: LogCallback 
     ); 
    } 


    void LogCallback(FBResult response) 
    { 
     Debug.Log(response.Text); 
     guiFeed.text = "response Feed:"+response.Text; 

     if (response.Text == null) 
     { 
      feedd.text = "not publish"; 
     } 
     else 
     { 
      feedd.text = " publish"; 
     } 

    } 


    #endregion 

답변

2

, 응답 cancelled 필드의 진정한 부울 값이 :

여기 내 코드입니다.

우선 JSON 문자열을 사전으로 구문 분석 한 다음 존재 여부와 양수 값인 취소 된 공유인지 확인해야합니다.

이 같은 코드를 업데이트해야합니다 을

:

void LogCallback(FBResult response) 
{ 
    var responseObject = Json.Deserialize(response.Text) as Dictionary<string, object>; 
    object cancelled; 
    if (responseObject.TryGetValue ("cancelled", out cancelled)) 
    { 
     if((bool)cancelled == true) 
     { 
      feedd.text = "not publish"; 
     } 
     else 
     { 
      feedd.text = "publish"; 
     } 
    } 
    else 
    { 
     feedd.text = "publish"; 
    } 
} 
+0

답변 주셔서 감사 많은,이 :) 꽤 잘 작동 – user3655933

관련 문제