Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        string     line = "{\"friends\":[{\"user\":{\"aboutMe\":\"\",\"avatar\":\"http://www.fitbit.com/images/profile/defaultProfile_100_male.gif\",\"city\":\"\",\"country\":\"\",\"dateOfBirth\":\"\",\"displayName\":\"Fitbit U.\",\"encodedId\":\"2246K9\",\"fullName\":\"Fitbit User\",\"gender\":\"NA\",\"height\":190.7,\"nickname\":\"\",\"offsetFromUTCMillis\":14400000,\"state\":\"\",\"strideLengthRunning\":0,\"strideLengthWalking\":0,\"timezone\":\"Europe/Moscow\",\"weight\":0}}]}";
        JSONObject list = new JSONObject(line);

        list.GetField("friends", delegate(JSONObject hits)
        {
            foreach (JSONObject user in hits.list)
            {
                Debug.Log(user);
                user.GetField("user", delegate(JSONObject info)
                {
                    Debug.Log("friends: ");
                    FriendModel model = new FriendModel(info);
                    Debug.Log(model.ToString());
                });
            }
        });
    }
Ejemplo n.º 2
0
        /**
         * Call from update loop in every scene.
         * At least in first scene
         * */
        public void Update()
        {
            if (DateTime.MinValue == lastUpdatedProfileTime || DateTime.Now - lastUpdatedProfileTime > TimeSpan.FromMinutes(MINUTES_OF_STALE_DATA))
            {
                shouldUpdate = true;
            }

            if (gotURL && !openedURL)
            {
                Debug.Log("Opening URL");
                openedURL = true;
                var url = SERVICE_SPECIFIC_AUTHORIZE_URL_STUB + manager[TOKEN_KEY];
                Application.OpenURL(url);
            }
            if (authenticated)
            {
                PlayerPrefs.SetString(TOKEN_KEY, manager[TOKEN_KEY]);
                PlayerPrefs.SetString(TOKEN_SECRET_KEY, manager[TOKEN_SECRET_KEY]);
                if (shouldUpdate)
                {
                    updateAll();
                }
                if (updateUserModel)
                {
                    PlayerPrefs.SetString(USER_MODEL_KEY, userModel.ToString());
                    updateUserModel = false;
                }
                if (updateUserFriends)
                {
                    string friendsString = "";
                    foreach (string model in friends)
                    {
                        friendsString += model + DELIMITER;
                    }
                    PlayerPrefs.SetString(USER_FRIENDS_KEY, friendsString);
                    updateUserFriends = false;
                }
            }
        }