private void FriendsUsingAppCallBack(IGraphResult result)
        {
            FBLog("FriendsDataCallBack", result.RawResult);
            FacebookHelperResultType resultType = FacebookHelperResultType.ERROR;

            if (result != null && result.Error == null)
            {
                JSONObject jsonObject = JSONObject.Parse(result.RawResult);
                JSONValue  dataArray  = jsonObject.GetArray("data");

                foreach (JSONValue friend in dataArray.Array)
                {
                    string userId   = friend.Obj.GetString("id");
                    string UserName = friend.Obj.GetString("name");
                    Debug.Log("NAME " + UserName);
                    if (PreloadFriendImages)
                    {
                        LoadProfileImage(userId);
                    }
                    FacebookFriend facebookFriend = new FacebookFriend();
                    facebookFriend.Id   = userId;
                    facebookFriend.Name = UserName;
                    Friends.Add(facebookFriend);
                }

                IsFriendsLoaded = true;
                resultType      = FacebookHelperResultType.OK;
            }

            OnFriendsUsingAppAction(resultType);
        }
Example #2
0
        void ShareMessengerCallback(IShareResult result)
        {
            FacebookHelperResultType resultType = FacebookHelperResultType.ERROR;

            if (result != null)
            {
                if (result.Error == null || result.Error == "")
                {
                    var    responseObject = Json.Deserialize(result.RawResult) as Dictionary <string, object>;
                    object obj            = 0;
                    if (responseObject.TryGetValue("cancelled", out obj))
                    {
                        resultType = FacebookHelperResultType.CANCELLED;
                    }
                    else if (responseObject.TryGetValue("id", out obj))
                    {
                        resultType = FacebookHelperResultType.OK;

                        if (doneCallback != null)
                        {
                            doneCallback();
                        }
                    }
                }
            }
        }
        private void PostCallBack(IShareResult result)
        {
            FBLog("PostCallBack", result.RawResult);
            FacebookHelperResultType resultType = FacebookHelperResultType.ERROR;

            if (result != null)
            {
                if (result.Error == null)
                {
                    var    responseObject = Json.Deserialize(result.RawResult) as Dictionary <string, object>;
                    object obj            = 0;
                    if (responseObject.TryGetValue("cancelled", out obj))
                    {
                        resultType = FacebookHelperResultType.CANCELLED;
                    }
                    else if (responseObject.TryGetValue("id", out obj))
                    {
                        resultType = FacebookHelperResultType.OK;
                    }
                }
            }
            OnPostingCompleteAction(resultType, result);
        }
        private void AppRequestCallBack(IAppRequestResult result)
        {
            FBLog("AppRequestCallBack", result.RawResult);
            FacebookHelperResultType resultType     = FacebookHelperResultType.ERROR;
            List <string>            InvitedFriends = new List <string>();

            if (result != null && result.Error == null)
            {
                JSONObject jsonObject = JSONObject.Parse(result.RawResult);
                if (jsonObject.ContainsKey("cancelled"))
                {
                    resultType = FacebookHelperResultType.CANCELLED;
                }
                else if (jsonObject.ContainsKey("request"))
                {
                    //{   "request": "420211088059698",
                    //    "to": [
                    //        "100002669403922",
                    //        "100000048490273"
                    //    ]}
                    resultType        = FacebookHelperResultType.OK;
                    HasInvitedFriends = true;

                    JSONValue to = jsonObject.GetArray("to");
                    if (to != null || to.Type == JSONValueType.Array)
                    {
                        NumberOfInvitesSent += to.Array.Length;
                        foreach (JSONValue value in to.Array)
                        {
                            InvitedFriends.Add(value.Str);
                            Debug.Log("Value: " + value.Str);
                        }
                    }
                }
            }
            OnAppRequestCompleteAction(resultType, InvitedFriends, result);
        }