Anirban Mookherjee
Anirban Mookherjee

Reputation: 53

Check for fb wall post success in unity

How to know if a wall post has been posted successfully on facebook using the facebook unity sdk? Is there any condition check for this like there is for login, FB.isLoggedIn? How to perform some action when the something was successfully posted?

Upvotes: 1

Views: 602

Answers (1)

archengineer
archengineer

Reputation: 26

You can use callback for this.

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

and in callback you have handle if post is success or not.

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
                }
            }
        }

Upvotes: 1

Related Questions