Exemple #1
0
 private void txtUserSub_Tapped(object sender, TappedRoutedEventArgs e)
 {
     //TODO: Get User sub Gallery
     BuisnessLayer.BLImgurAPI bl = new BuisnessLayer.BLImgurAPI();
     JsonObject json = bl.GetGallery("user", "time", true, 1);
     //TODO: Process JSON
     //TODO: Display Content
 }
Exemple #2
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            MenuAnimationOpen.Begin();
            //Get Locally stored OAuth token
            DataLayer.Settings settings = new DataLayer.Settings();
            //settings.ClearOAuth();
            oat = settings.GetOAuth();         

            if (oat.Authenticated)
            {
                //refresh OAuth Token if it's about to expire or is expired
                if(oat.Expires>=DateTime.Now.AddDays(-7))
                { 
                    BuisnessLayer.BLImgurAPI bl = new BuisnessLayer.BLImgurAPI();
                    oat=bl.RefreshOAuth(oat);
                }
                txtUsername.Text = "\n" + oat.User.Url;
            }
        }
Exemple #3
0
        private void wvAuthenticate_LoadCompleted(object sender, NavigationEventArgs e)
        {
            if (wvAuthenticate.Source.ToString().Contains("https://imgur.com/?state=Authorization#"))
            {
                String url = wvAuthenticate.Source.ToString();
                //remove garbage
                url=url.Replace("https://imgur.com/?state=Authorization#","");
                if(url.Contains("access_token=") & url.Contains("refresh_token=") & url.Contains("expires_in") & url.Contains("account_username") & url.Contains("account_id="))
                {
                    wvAuthenticate.Visibility = Visibility.Collapsed;

                    BuisnessLayer.BLImgurAPI bl = new BuisnessLayer.BLImgurAPI();
                    DataLayer.ImgurUser usr;
                    DataLayer.Settings settings = new DataLayer.Settings();
                    String[] split = url.Split('&');
                    oat.Authenticated = true;
                    oat.Expires = DateTime.Now.AddSeconds(Double.Parse(split[1].Split('=')[1]));
                    oat.Token = split[0].Split('=')[1];
                    oat.RefreshToken = split[3].Split('=')[1];
                    usr=bl.logIn(split[4].Split('=')[1],oat.Token);
                    oat.User = usr;
                    txtUsername.Text = "\n" + usr.Url;
                    settings.StoreOAuth(oat); //Store OAuth Token locally
                                        
                    wvAuthenticate.Source = new Uri("about:blank");
                }

            }
        }