Exemplo n.º 1
0
 void UpdateFacebookInfo(StardomAPICallback callback = null)
 {
     socialHandler.GetFacebookInfo((FacebookInfoReply reply) =>
     {
         if (reply.Success)
         {
             Debug.Log(string.Format("Fb info, gender: {0}, country: {1}, birthdate: {2}", reply.gender, reply.country, reply.gender));
             cloudHandler.UpdateFacebookInfo(reply, (StardomAPIReply updateReply) =>
             {
                 if (callback != null)
                 {
                     callback(updateReply);
                 }
             });
         }
         else
         {
             Debug.Log("Failed to fetch fb info, " + reply.ErrorMessage);
             if (callback != null)
             {
                 callback(new StardomAPIReply(false, "Failed to fetch fb info, " + reply.ErrorMessage));
             }
         }
     });
 }
Exemplo n.º 2
0
        void FBLoginCallback(ILoginResult result, StardomAPICallback callback)
        {
            string error = "";

            if (result == null)
            {
                error = "Facebook returned null reply";
            }
            else if (!string.IsNullOrEmpty(result.Error))
            {
                error = result.Error;
            }
            else if (string.IsNullOrEmpty(result.RawResult))
            {
                error = "Facebook returned empty result";
            }
            else if (!FB.IsLoggedIn)
            {
                error = "Facebook not logged in";
            }

            if (callback != null)
            {
                callback(new StardomAPIReply(string.IsNullOrEmpty(error), error));
            }
            else if (!string.IsNullOrEmpty(error))
            {
                Debug.LogWarning("SocialHandler: FB login failed with no callback. Error: " + error);
            }
        }
Exemplo n.º 3
0
 public void FacebookLogin(StardomAPICallback callback = null, bool publishPermission = false)
 {
     if (publishPermission)
     {
         FB.LogInWithPublishPermissions(APIConsts.facebookScope, delegate(ILoginResult result) { FBLoginCallback(result, callback); });
     }
     else
     {
         FB.LogInWithReadPermissions(APIConsts.facebookScope, delegate(ILoginResult result) { FBLoginCallback(result, callback); });
     }
 }
Exemplo n.º 4
0
    //void OnDestroy()
    //{
    //    cloudHandler.Disconnect();
    //}

    public void Login(StardomAPICallback callback = null)
    {
        if (!IsInitialized)
        {
            Debug.LogError("Trying to call StardomAPI functions before it's fully initialized");
            return;
        }

        socialHandler.FacebookLogin(delegate(StardomAPIReply reply)
        {
            if (!reply.Success)
            {
                //if authentication fails return the same object with the same message
                if (callback != null)
                {
                    callback(reply);
                }
            }
            else
            {
                // if facebook login succeeds, continue with cloud authentication
                cloudHandler.AuthenticateFacebookUser(socialHandler.Token, (AuthReply rep) =>
                {
                    //try to update user info from fb if needed from server
                    if (rep.Success && rep.updateFromFb || true)
                    {
                        UpdateFacebookInfo((StardomAPIReply updateReply) =>
                        {
                            if (callback != null)
                            {
                                callback(updateReply);
                            }
                        });
                    }
                    else if (callback != null)
                    {
                        callback(rep);
                    }
                });
            }
        });
    }
Exemplo n.º 5
0
        public void BidOnUser(string uid, StardomAPICallback callback)
        {
            LogEventRequest_BidOnUser req = new LogEventRequest_BidOnUser();

            req.Set_id(uid);
            req.Send((response) =>
            {
                if (callback != null)
                {
                    if (response.HasErrors)
                    {
                        callback(new StardomAPIReply(false, "Unexpected error occured"));
                    }
                    else
                    {
                        callback(CloudConverter.LogEventErrorToAPIReply(response));
                    }
                }
            });
        }
Exemplo n.º 6
0
        public void UpdateFacebookInfo(FacebookInfoReply reply, StardomAPICallback callback = null)
        {
            LogEventRequest_UpdateFacebookInfo req = new LogEventRequest_UpdateFacebookInfo();

            req.Set_gender(reply.gender);
            req.Set_birthdate(reply.birthdate);

            req.Send((response) =>
            {
                if (callback != null)
                {
                    if (response.HasErrors)
                    {
                        callback(new StardomAPIReply(false, "GS failed to update fb info, " + response.Errors.ToString()));
                    }
                    else
                    {
                        callback(new StardomAPIReply(true));
                    }
                }
            });
        }
Exemplo n.º 7
0
 public void BidOnUser(string uid, StardomAPICallback callback)
 {
     cloudHandler.BidOnUser(uid, callback);
 }