예제 #1
0
파일: Settings.cs 프로젝트: ninijay/Wingur
        public OAuthToken GetOAuth()
        {
            var localSettings = ApplicationData.Current.LocalSettings;
            OAuthToken o = new OAuthToken();
            ImgurUser u = new ImgurUser();

            try {
                u.Bio = (string)localSettings.Values["User_Bio"];
                u.Created = (int)localSettings.Values["User_Created"];
                u.Id = (int)localSettings.Values["User_Id"];
                u.Pro = (int)localSettings.Values["User_Pro"];
                u.Rep = (float)localSettings.Values["User_Rep"];
                u.Url = (string)localSettings.Values["User_Url"];
                o.Authenticated = (bool)localSettings.Values["Authenticated"];
                o.Expires = DateTime.FromBinary((long)localSettings.Values["Expires"]);
                o.RefreshToken = (string)localSettings.Values["RefreshToken"];
                o.Token = (string)localSettings.Values["Token"];
                o.User = u;

                BuisnessLayer.BLImgurAPI bl = new BuisnessLayer.BLImgurAPI();
                u = bl.logIn(u.Url, o.Token);
                o.User = u;
            }
            catch
            {
                o = new OAuthToken();
                u = new ImgurUser();
                o.User = u;
            }

            return o;
        }
예제 #2
0
        private DataLayer.ImgurUser logIn(string username, String OAuth = null)
        {
            DataLayer.ImgurUser user;
            //------------------------

            HttpClient client = GetHttpClient(OAuth);

            string URI = BaseURL;

            URI += "account/" + username + ".json";

            var        jsonStr = client.GetStringAsync(URI).Result;
            JsonObject json    = new JsonObject();

            JsonObject.TryParse(jsonStr, out json);

            //TODO: Process JSON
            user = new DataLayer.ImgurUser();
            // user.id = ...
            // etc...
            // throw new Exception("Method not implemented yet");

            // return logged in user:
            return(user);
        }
예제 #3
0
        private DataLayer.ImgurUser logIn(string username, String OAuth = null)
        {
            DataLayer.ImgurUser user;
            //------------------------

            HttpClient client = GetHttpClient(OAuth);

            string URI = BaseURL;
            URI += "account/" + username + ".json";

            var jsonStr = client.GetStringAsync(URI).Result;
            JsonObject json = new JsonObject();
            JsonObject.TryParse(jsonStr, out json);

            //TODO: Process JSON
            user = new DataLayer.ImgurUser();
            // user.id = ...
            // etc...
            // throw new Exception("Method not implemented yet");

            // return logged in user:
            return user;
        }