コード例 #1
20
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            try {
                //HttpClient clientOb = new HttpClient();
                //Uri connectionUrl = new Uri("http://mydomain.com/request.php");
                //string pairs = ID.Text;
                //HttpStringContent formcontent = new HttpStringContent(pairs, 0);

                //HttpResponseMessage response = await clientOb.PostAsync(connectionUrl, formcontent);
                //if (response.IsSuccessStatusCode)
                //{
                Windows.Web.Http.HttpClient client = new Windows.Web.Http.HttpClient();
               
                var jsonText = await client.GetStringAsync(new Uri("http://www.bits-oasis.org/2015/pcode_json/?email="+ID.Text));
                //if(jsonText.Length==0)
                //{
                //    var dialog1 = new MessageDialog("ID not found");
                //    await dialog1.ShowAsync();
                //}
                jsonText =jsonText.Substring(11);
                
                int l = jsonText.Length;
                l = l - 2;
                jsonText= jsonText.Remove(l);
                //{ "pcode": "car5417"}
                if (jsonText.CompareTo("0") == 0)
                {
                    var dialog1 = new MessageDialog("ID not found");
                    await dialog1.ShowAsync();
                }
                else
                {
                    var dialog = new MessageDialog("Your ID is - " + jsonText);
                    await dialog.ShowAsync();
                }
            }
            catch { }
            }
コード例 #2
2
ファイル: XmlQuery.cs プロジェクト: razeheb/limelight-wp
        /// <summary>
        /// Gets the Xml as a string from the URL provided
        /// </summary>
        /// <returns>The server info XML as a string</returns>
        private async Task GetXml()
        {
            HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();
            filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
            filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.InvalidName);

            IEnumerable<Certificate> certificates = await CertificateStores.FindAllAsync(new CertificateQuery { FriendlyName = "Limelight-Client" });
            filter.ClientCertificate = certificates.Single();

            client = new Windows.Web.Http.HttpClient(filter);
            Debug.WriteLine(uri);
            if (rawXmlString == null)
            {
                try
                {
                    rawXmlString = await client.GetStringAsync(uri);
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }
                Debug.WriteLine(rawXmlString);
                
                // Up to the caller to deal with exceptions resulting here
                this.rawXml = XDocument.Parse(rawXmlString);

                
            }
        }
コード例 #3
1
        /// <summary>
        /// Gets the Xml as a string from the URL provided
        /// </summary>
        /// <returns>The server info XML as a string</returns>
        private async Task GetXml()
        {
            // Return if we've already been here
            if (ranQuery)
            {
                return;
            }
            else
            {
                ranQuery = true;
            }

            HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();
            filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
            filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.InvalidName);

            // Allow the crypto provider to generate the cert if needed
            await new WindowsCryptoProvider().InitializeCryptoProviderKeys();

            IEnumerable<Certificate> certificates = await CertificateStores.FindAllAsync(new CertificateQuery { FriendlyName = "Limelight-Client" });
            filter.ClientCertificate = certificates.Single();

            client = new Windows.Web.Http.HttpClient(filter);
            Debug.WriteLine(uri);

            try
            {
                rawXmlString = await client.GetStringAsync(uri);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                return;
            }

            Debug.WriteLine(rawXmlString);

            // Up to the caller to deal with exceptions resulting here
            this.rawXml = XDocument.Parse(rawXmlString);
        }
コード例 #4
1
ファイル: TwitterClient.cs プロジェクト: matdestr/Twitter
        private async Task<String> SendDataAsync(String Url)
        {
            try
            {
                Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();
                return await httpClient.GetStringAsync(new Uri(Url));
            }
            catch (Exception Err)
            {
                //rootpage.NotifyUser("Error getting data from server." + Err.Message, NotifyType.StatusMessage);
            }

            return null;
        }
コード例 #5
0
        public static async Task <string> GetEncryptedPassword(string passWord)
        {
            string base64String;

            try
            {
                //https://secure.bilibili.com/login?act=getkey&rnd=4928
                //https://passport.bilibili.com/login?act=getkey&rnd=4928
                HttpBaseProtocolFilter httpBaseProtocolFilter = new HttpBaseProtocolFilter();
                httpBaseProtocolFilter.IgnorableServerCertificateErrors.Add(Windows.Security.Cryptography.Certificates.ChainValidationResult.Expired);
                httpBaseProtocolFilter.IgnorableServerCertificateErrors.Add(Windows.Security.Cryptography.Certificates.ChainValidationResult.Untrusted);
                Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient(httpBaseProtocolFilter);
                //WebClientClass wc = new WebClientClass();
                string stringAsync = await httpClient.GetStringAsync((new Uri("https://passport.bilibili.com/login?act=getkey&rnd=" + new Random().Next(1000, 9999), UriKind.Absolute)));

                JObject jObjects = JObject.Parse(stringAsync);
                string  str      = jObjects["hash"].ToString();
                string  str1     = jObjects["key"].ToString();
                string  str2     = string.Concat(str, passWord);
                string  str3     = Regex.Match(str1, "BEGIN PUBLIC KEY-----(?<key>[\\s\\S]+)-----END PUBLIC KEY").Groups["key"].Value.Trim();
                byte[]  numArray = Convert.FromBase64String(str3);
                AsymmetricKeyAlgorithmProvider asymmetricKeyAlgorithmProvider = AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithmNames.RsaPkcs1);
                CryptographicKey cryptographicKey = asymmetricKeyAlgorithmProvider.ImportPublicKey(WindowsRuntimeBufferExtensions.AsBuffer(numArray), 0);
                IBuffer          buffer           = CryptographicEngine.Encrypt(cryptographicKey, WindowsRuntimeBufferExtensions.AsBuffer(Encoding.UTF8.GetBytes(str2)), null);
                base64String = Convert.ToBase64String(WindowsRuntimeBufferExtensions.ToArray(buffer));
            }
            catch (Exception)
            {
                //throw;
                base64String = passWord;
            }
            return(base64String);
        }
コード例 #6
0
        /// <summary>
        /// Gets the Xml as a string from the URL provided
        /// </summary>
        /// <returns>The server info XML as a string</returns>
        private async Task GetXml()
        {
            HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();

            filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
            filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.InvalidName);

            IEnumerable <Certificate> certificates = await CertificateStores.FindAllAsync(new CertificateQuery { FriendlyName = "Limelight-Client" });

            filter.ClientCertificate = certificates.Single();

            client = new Windows.Web.Http.HttpClient(filter);
            Debug.WriteLine(uri);
            if (rawXmlString == null)
            {
                try
                {
                    rawXmlString = await client.GetStringAsync(uri);
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }
                Debug.WriteLine(rawXmlString);

                // Up to the caller to deal with exceptions resulting here
                this.rawXml = XDocument.Parse(rawXmlString);
            }
        }
コード例 #7
0
 /// <summary>
 /// Gets the Xml as a string from the URL provided
 /// </summary>
 /// <returns>The server info XML as a string</returns>
 private async Task GetXml()
 {
     Debug.WriteLine(uri);
     if (rawXmlString == null)
     {
         try
         {
             rawXmlString = await client.GetStringAsync(uri);
         }
         catch (Exception e)
         {
             Debug.WriteLine(e.Message);
         }
         Debug.WriteLine(rawXmlString);
         try
         {
             this.rawXml = XDocument.Parse(rawXmlString);
         }
         catch (Exception ex)
         {
             Debug.WriteLine(ex.Message);
             Debug.WriteLine(ex.StackTrace);
             Debug.WriteLine(ex.InnerException);
         }
     }
 }
コード例 #8
0
ファイル: MainPage.xaml.cs プロジェクト: Nindzzya/playground
        public async void updateIp(object state)
        {
            await Window.Current.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                                                () => { statusTb.Text = "Updating Local IP..."; });

            var getip    = new Windows.Web.Http.HttpClient();
            var htmlbody = await getip.GetStringAsync(new Uri("http://checkip.dyndns.org/"));

            var        substring  = htmlbody.ToString().Replace("<html><head><title>Current IP Check</title></head><body>Current IP Address: ", "");
            var        internetip = substring.ToString().Replace("</body></html>\r\n", "");
            HttpClient client     = new HttpClient();

            client.DefaultRequestHeaders.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue(
                "Basic",
                Convert.ToBase64String(
                    System.Text.ASCIIEncoding.ASCII.GetBytes(
                        string.Format("{0}:{1}", "kesava", "95123456"))));
            var resp = await client.GetAsync(new Uri("http://dynupdate.no-ip.com/nic/update?hostname=kesava89.ddns.net&myip=" + internetip));

            var respType = resp.EnsureSuccessStatusCode();

            if (respType.IsSuccessStatusCode)
            {
                await Window.Current.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                                                    () => { statusTb.Text = "Updating Local IP complete."; });
            }
            else
            {
                await Window.Current.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                                                    () => { statusTb.Text = "Please check your internet connection or contact admin. Code: " + respType.StatusCode; });
            }
        }
コード例 #9
0
        private async void GetHoloPoints(object sender, object e)
        {
            var uri = new System.Uri("https://holotest-6cd6b.firebaseio.com/HoloPoints.json");

            using (var httpClient = new Windows.Web.Http.HttpClient())
            {
                // Always catch network exceptions for async methods
                try
                {
                    //string result = "{\"FarBottomLeftX\":\" - 0.53\",\"FarBottomLeftY\":\" - 0.30\",\"FarBottomLeftZ\":\"2.08\",\"FarBottomRightX\":\"0.53\",\"FarBottomRightY\":\" - 0.30\",\"FarBottomRightZ\":\"2.08\",\"FarTopLeftX\":\" - 0.53\",\"FarTopLeftY\":\"0.30\",\"FarTopLeftZ\":\"2.08\",\"FarTopRightX\":\"0.53\",\"FarTopRightY\":\"0.30\",\"FarTopRightZ\":\"2.08\",\"NearBottomLeftX\":\" - 0.53\",\"NearBottomLeftY\":\" - 0.30\",\"NearBottomLeftZ\":\"0.00\",\"NearBottomRightX\":\"0.53\",\"NearBottomRightY\":\" - 0.30\",\"NearBottomRightZ\":\"0.00\",\"NearTopLeftX\":\" - 0.53\",\"NearTopLeftY\":\"0.30\",\"NearTopLeftZ\":\"0.00\",\"NearTopRightX\":\"0.53\",\"NearTopRightY\":\"0.30\",\"NearTopRightZ\":\"0.00\"}";//await httpClient.GetStringAsync(uri);
                    string result = await httpClient.GetStringAsync(uri);

                    Dictionary <string, Dictionary <string, string> > parentDict = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, string> > >(result);

                    Dictionary <string, string> childDict = parentDict.Values.First();

                    WebServiceTxt.Text = childDict["FarBottomLeftX"];

                    Point3D topLeftpt = new Point3D();
                    topLeftpt.x = float.Parse(childDict["NearTopLeftX"]);
                    topLeftpt.y = float.Parse(childDict["NearTopLeftY"]);
                    topLeftpt.z = float.Parse(childDict["NearTopLeftZ"]);

                    Point3D topRightpt = new Point3D();
                    topRightpt.x = float.Parse(childDict["NearTopRightX"]);
                    topRightpt.y = float.Parse(childDict["NearTopRightY"]);
                    topRightpt.z = float.Parse(childDict["NearTopRightZ"]);

                    Point3D bottomLeftpt = new Point3D();
                    bottomLeftpt.x = float.Parse(childDict["NearBottomLeftX"]);
                    bottomLeftpt.y = float.Parse(childDict["NearBottomLeftY"]);
                    bottomLeftpt.z = float.Parse(childDict["NearBottomLeftZ"]);

                    Point3D bottomRightpt = new Point3D();
                    bottomRightpt.x = float.Parse(childDict["NearBottomRightX"]);
                    bottomRightpt.y = float.Parse(childDict["NearBottomRightY"]);
                    bottomRightpt.z = float.Parse(childDict["NearBottomRightZ"]);

                    DebugTxt.Text += " topLeftpt.x:  " + topLeftpt.x + " topLeftpt.y:   " + topLeftpt.y + " topLeftpt.z:   " + topLeftpt.z + "  " +
                                     " topRightpt.x:  " + topRightpt.x + " topRightpt.y:  " + topRightpt.y + " topRightpt.z:  " + topRightpt.z + "  " +
                                     " bottomLeftpt.x:  " + bottomLeftpt.x + " bottomLeftpt.y:  " + bottomLeftpt.y + " bottomLeftpt.z:  " + bottomLeftpt.z + "  " +
                                     " bottomRightpt.x:  " + bottomRightpt.x + " bottomRightpt.y:  " + bottomRightpt.y + " bottomRightpt.z:  " + bottomRightpt.z;



                    HoloPoints.Instance.topLeftpt     = topLeftpt;
                    HoloPoints.Instance.topRightpt    = topRightpt;
                    HoloPoints.Instance.bottomLeftpt  = bottomLeftpt;
                    HoloPoints.Instance.bottomRightpt = bottomRightpt;


                    Windows.Web.Http.HttpResponseMessage response = await httpClient.DeleteAsync(uri);
                }
                catch (Exception ex)
                {
                    WebServiceTxt.Text = ex.Message;
                }
            }
        }
コード例 #10
0
ファイル: ExClient.cs プロジェクト: SettingDust/PRPR
        public static async Task <string> GetStringWithExCookie(string uriString, string uconfig = "")
        {
            var client = new Windows.Web.Http.HttpClient();

            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Add("Cookie", await GetExCookieAsync(uconfig));
            client.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate");
            var str = await client.GetStringAsync(new Uri(uriString));

            return(str);
        }
コード例 #11
0
ファイル: HomeViewModel.cs プロジェクト: WindowsT10/frontend
        public async void LoadPassenger(GeneralLogin generalLogin)
        {
            Windows.Web.Http.HttpClient client = new Windows.Web.Http.HttpClient();
            try
            {
                var json = await client.GetStringAsync(new Uri("http://localhost:5000/api/User/passenger/" + generalLogin.Login));

                var passenger = JsonConvert.DeserializeObject <Model.Passenger>(json);
                if (passenger != null)
                {
                    Flight = passenger.Flight;
                }
            }
            catch (Exception) {};
        }
コード例 #12
0
ファイル: UserViewModel.cs プロジェクト: TI3-Windows/Windows
        public async Task <User> GetUserDetails(String access_token)
        {
            string     token      = access_token;
            HttpClient httpClient = new HttpClient();

            try
            {
                httpClient.DefaultRequestHeaders.Authorization = new HttpCredentialsHeaderValue("Bearer", token);
                var response = await httpClient.GetStringAsync(new Uri("http://localhost:5001/api/Customer"));

                User = JsonConvert.DeserializeObject <User>(response);
                User.access_token = token;
                return(User);
            } catch (Exception)
            {
                return(null);
            }
        }
コード例 #13
0
        /// <summary>
        /// Gets the Xml as a string from the URL provided
        /// </summary>
        /// <returns>The server info XML as a string</returns>
        private async Task GetXml()
        {
            // Return if we've already been here
            if (ranQuery)
            {
                return;
            }
            else
            {
                ranQuery = true;
            }

            HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();

            filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
            filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.InvalidName);

            // Allow the crypto provider to generate the cert if needed
            await new WindowsCryptoProvider().InitializeCryptoProviderKeys();

            IEnumerable <Certificate> certificates = await CertificateStores.FindAllAsync(new CertificateQuery { FriendlyName = "Limelight-Client" });

            filter.ClientCertificate = certificates.Single();

            client = new Windows.Web.Http.HttpClient(filter);
            Debug.WriteLine(uri);

            try
            {
                rawXmlString = await client.GetStringAsync(uri);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                return;
            }

            Debug.WriteLine(rawXmlString);

            // Up to the caller to deal with exceptions resulting here
            this.rawXml = XDocument.Parse(rawXmlString);
        }
コード例 #14
0
        private async void loadTravellists()
        {
            //var travelLists = User.Travellists;
            try
            {
                HttpClient httpClient = new HttpClient();
                var        token      = Globals.LoggedInUser.access_token;
                httpClient.DefaultRequestHeaders.Authorization = new HttpCredentialsHeaderValue("Bearer", token);
                var response = await httpClient.GetStringAsync(new Uri("http://localhost:5001/api/Travellist/User"));

                var travelLists = JsonConvert.DeserializeObject <IList <Travellist> >(response);
                foreach (var tl in travelLists)
                {
                    Travellists.Add(tl);
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #15
0
ファイル: YandeClient.cs プロジェクト: SettingDust/PRPR
        private static async Task <string> GetAuthenticityToken()
        {
            try
            {
                // Log out
                HttpWebRequest logoutRequest = WebRequest.CreateHttp($"https://yande.re/user/logout");
                logoutRequest.CookieContainer = new CookieContainer();
                using (HttpWebResponse logResponse = (HttpWebResponse)(await logoutRequest.GetResponseAsync()))
                {
                    using (Stream stream = logResponse.GetResponseStream())
                    {
                        StreamReader reader         = new StreamReader(stream, Encoding.UTF8);
                        string       responseString = reader.ReadToEnd();

                        var x = logResponse.Cookies;
                        foreach (Cookie item in x)
                        {
                            Debug.WriteLine(WebUtility.UrlDecode(item.Value));
                        }
                    }
                }


                HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();
                filter.CacheControl.WriteBehavior = HttpCacheWriteBehavior.NoCache;
                filter.CacheControl.ReadBehavior  = HttpCacheReadBehavior.MostRecent;
                filter.AllowUI = false;
                var hc  = new Windows.Web.Http.HttpClient(filter);
                var str = await hc.GetStringAsync(new Uri($"https://yande.re/user/login"));

                var start = str.IndexOf("<meta name=\"csrf-token\" content=\"") + "<meta name=\"csrf-token\" content=\"".Length;
                var end   = str.IndexOf("\" />", start);
                str = str.Substring(start, end - start);
                return(WebUtility.UrlEncode(str));
            }
            catch (Exception ex)
            {
                return("");
            }
        }
コード例 #16
-1
ファイル: TwitterClient.cs プロジェクト: matdestr/Twitter
        public async Task<string> GetTwitterRequestTokenAsync(string twitterCallbackUrl, string consumerKey)
        {
            // 
            // Acquiring a request token 
            // 
            string TwitterUrl = "https://api.twitter.com/oauth/request_token";

            string nonce = GetNonce();
            string timeStamp = GetTimeStamp();
            string SigBaseStringParams = "oauth_callback=" + Uri.EscapeDataString(twitterCallbackUrl);
            SigBaseStringParams += "&" + "oauth_consumer_key=" + consumerKey;
            SigBaseStringParams += "&" + "oauth_nonce=" + nonce;
            SigBaseStringParams += "&" + "oauth_signature_method=HMAC-SHA1";
            SigBaseStringParams += "&" + "oauth_timestamp=" + timeStamp;
            SigBaseStringParams += "&" + "oauth_version=1.0";
            string SigBaseString = "GET&";
            SigBaseString += Uri.EscapeDataString(TwitterUrl) + "&" + Uri.EscapeDataString(SigBaseStringParams);
            string Signature = GetSignature(SigBaseString);

            TwitterUrl += "?" + SigBaseStringParams + "&oauth_signature=" + Uri.EscapeDataString(Signature);
            Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();
            string GetResponse = await httpClient.GetStringAsync(new Uri(TwitterUrl));

            //          DebugPrint("Received Data: " + GetResponse); 

            string request_token = null;
            string oauth_token_secret = null;
            string[] keyValPairs = GetResponse.Split('&');

            for (int i = 0; i < keyValPairs.Length; i++)
            {
                string[] splits = keyValPairs[i].Split('=');
                switch (splits[0])
                {
                    case "oauth_token":
                        request_token = splits[1];
                        break;
                    case "oauth_token_secret":
                        oauth_token_secret = splits[1];
                        break;
                }
            }
            o_auth_token = request_token;
            DebugPrint(o_auth_token);
            return request_token;
        }
コード例 #17
-6
ファイル: ApiHelper.cs プロジェクト: GeminiLab/BiliBili-UWP
 public static async Task<string> GetEncryptedPassword(string passWord)
 {
     string base64String;
     try
     {
         //https://secure.bilibili.com/login?act=getkey&rnd=4928
         //https://passport.bilibili.com/login?act=getkey&rnd=4928
         HttpBaseProtocolFilter httpBaseProtocolFilter = new HttpBaseProtocolFilter();
         httpBaseProtocolFilter.IgnorableServerCertificateErrors.Add(Windows.Security.Cryptography.Certificates.ChainValidationResult.Expired);
         httpBaseProtocolFilter.IgnorableServerCertificateErrors.Add(Windows.Security.Cryptography.Certificates.ChainValidationResult.Untrusted);
         Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient(httpBaseProtocolFilter);
        //WebClientClass wc = new WebClientClass();
         string stringAsync =  await httpClient.GetStringAsync((new Uri("https://secure.bilibili.com/login?act=getkey&rnd=" + new Random().Next(1000,9999), UriKind.Absolute)));
         JObject jObjects = JObject.Parse(stringAsync);
         string str = jObjects["hash"].ToString();
         string str1 = jObjects["key"].ToString();
         string str2 = string.Concat(str, passWord);
         string str3 = Regex.Match(str1, "BEGIN PUBLIC KEY-----(?<key>[\\s\\S]+)-----END PUBLIC KEY").Groups["key"].Value.Trim();
         byte[] numArray = Convert.FromBase64String(str3);
         AsymmetricKeyAlgorithmProvider asymmetricKeyAlgorithmProvider = AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithmNames.RsaPkcs1);
         CryptographicKey cryptographicKey = asymmetricKeyAlgorithmProvider.ImportPublicKey(WindowsRuntimeBufferExtensions.AsBuffer(numArray), 0);
         IBuffer buffer = CryptographicEngine.Encrypt(cryptographicKey, WindowsRuntimeBufferExtensions.AsBuffer(Encoding.UTF8.GetBytes(str2)), null);
         base64String = Convert.ToBase64String(WindowsRuntimeBufferExtensions.ToArray(buffer));
 }
     catch (Exception)
     {
         throw;
         //base64String = pw;
     }
     return base64String;
 }