Exemple #1
0
    void CallbackInvitableFriends(IResult result)
    {
        if (!string.IsNullOrEmpty(result.Error))
        {
            Debug.Log("## CallbackInvitableFriends #Error = " + result.Error);
            return;
        }

#if UNITY_EDITOR
        PlayerPrefHelper.SetFBInvitableFriendsResult(result.RawResult);
#endif
        string strResult = result.RawResult;
        strResult = strResult.Replace(@"\/", @"/");
        Debug.Log("## CallbackInvitableFriends >> strResult = " + strResult);

        _FBInvitableFriends = new FBInvitableFriendsVO(strResult);
        //CLog.Log2(TAG, "CallbackInvitableFriends >> after parse = " + _invitableFriendsVO.DebugString());
    }
Exemple #2
0
    IEnumerator LoadInvitableFriends(System.Action complete)
    {
        yield return(new WaitForSeconds(1.0f));

        string meQueryString = "/me?fields=id,name,invitable_friends.limit(50).fields(name,id,picture.width(100).height(100))";

        //FB.API(meQueryString, HttpMethod.GET, APICallback);
        FB.API("me/invitable_friends?fields=id,name,picture.width(300)", HttpMethod.GET, (result) => {
            if (!string.IsNullOrEmpty(result.Error))
            {
                Debug.Log("## LoadInvitableFriends #Error = " + result.Error);

                if (complete != null)
                {
                    complete();
                }
                return;
            }

            if (result.Cancelled)
            {
                if (complete != null)
                {
                    complete();
                }
                return;
            }

#if UNITY_EDITOR
            PlayerPrefHelper.SetFBInvitableFriendsResult(result.RawResult);
#endif
            string strResult = result.RawResult;
            strResult        = strResult.Replace(@"\/", @"/");
            Debug.Log("## CallbackInvitableFriends >> strResult = " + strResult);

            _FBInvitableFriends = new FBInvitableFriendsVO(strResult);
            //CLog.Log2(TAG, "CallbackInvitableFriends >> after parse = " + _invitableFriendsVO.DebugString());

            if (complete != null)
            {
                complete();
            }
        });
    }
Exemple #3
0
    /// <summary>
    /// 인증이 안된 유저의 첫 페이스북 로그인
    /// </summary>
    public void FBLogin(OnUserInfoCallback complete)
    {
#if UNITY_EDITOR
        string tempResult = PlayerPrefHelper.GetFBLoginResult();
        if (!string.IsNullOrEmpty(tempResult))
        {
            // 유저 정보
            string strResult = tempResult.Replace(@"\/", @"/");
            _fbLoginVO = new FBLoginVO(strResult);
            // frineds
            tempResult = PlayerPrefHelper.GetFBFriendsResult();
            if (!string.IsNullOrEmpty(tempResult))
            {
                strResult      = tempResult.Replace(@"\/", @"/");
                _FBFriends     = new FBAppFriendsVO(strResult);
                _AppFriendsIDs = new List <string>();
                for (int i = 0; i < _FBFriends._packet.data.Length; i++)
                {
                    if (_FBFriends._packet.data[i].installed)
                    {
                        _AppFriendsIDs.Add(_FBFriends._packet.data[i].id);
                    }
                }
            }
            // Invitable frineds
            tempResult          = PlayerPrefHelper.GetFBInvitableFriendsResult();
            strResult           = tempResult.Replace(@"\/", @"/");
            _FBInvitableFriends = new FBInvitableFriendsVO(strResult);

            if (complete != null)
            {
                complete(true);
            }
            return;
        }
#endif

        var perms = new List <string>()
        {
            "public_profile", "email", "user_friends"
        };
        FB.LogInWithReadPermissions(perms, (result) =>
        {
            if (result == null)
            {
                if (complete != null)
                {
                    complete(false);
                }
                return;
            }
            if (!string.IsNullOrEmpty(result.Error))
            {
                Debug.Log("## FBController : CallbackUserInfo >> Error = " + result.Error);
                if (complete != null)
                {
                    complete(false);
                }
            }
            else if (result.Cancelled)
            {
                Debug.Log("## FBController : CallbackUserInfo >> Cancelled = " + result.Cancelled);
                if (complete != null)
                {
                    complete(false);
                }
            }
            else if (!string.IsNullOrEmpty(result.RawResult))
            {
                xLitJson.JsonData data = xLitJson.JsonMapper.ToObject(result.RawResult);
                string strAccessToken  = (string)data["access_token"];
                PlayerPrefHelper.SetFbAccessToken(strAccessToken);
                Debug.Log("## FBController : CallbackAuth >> Success Response = " + result.RawResult);
                LoadUserInfo(complete);
            }
        });
    }