检查fb墙成功的统一性

时间:2014-12-22 11:10:55

标签: facebook-unity-sdk

如何使用facebook unity sdk在facebook上成功发布墙贴?是否有任何条件检查,如登录,FB.isLoggedIn?如果成功发布某些内容,如何执行某些操作?

1 个答案:

答案 0 :(得分:1)

您可以使用回调。

FB.Feed("", link, message, caption, linkName, linkToImage, "", "", "", "", null, OnActionShared);

如果帖子成功与否,你可以在回调中处理。

public void OnActionShared(FBResult result){
            if(result.Error != null)
            {
                Debug.LogError("OnActionShared: Error: " + result.Error);
            }

            if (result == null || result.Error != null)
            {
                //Do something request failed
            }
            else
            {
                var responseObject = Json.Deserialize(result.Text) as Dictionary<string, object>;
                object obj = 0;
                if (responseObject == null || responseObject.Count <= 0 || responseObject.TryGetValue("cancelled", out obj))
                {
                    Debug.LogWarning("Request cancelled");
                    //Do something when user cancelled
                }
                else if (responseObject.TryGetValue("id", out obj) || responseObject.TryGetValue("post_id", out obj))
                {
                    Debug.LogWarning("Request Send");

                    //Do something it is succeeded
                }
            }
        }