Ejemplo n.º 1
0
 override public string[] getAccessTokenJSON(string code)
 {
     Leaf.xNet.HttpResponse tokenResponse = null;
     string[] result = new string[2];
     using (var tokenRequest = new Leaf.xNet.HttpRequest())
     {
         RequestParams requestParams = new RequestParams();
         requestParams.Add(new KeyValuePair <string, string>("client_id", applicationId));
         requestParams.Add(new KeyValuePair <string, string>("client_secret", applicationSecret));
         requestParams.Add(new KeyValuePair <string, string>("grant_type", "authorization_code"));
         requestParams.Add(new KeyValuePair <string, string>("redirect_uri", redirectUri));
         requestParams.Add(new KeyValuePair <string, string>("code", code));
         tokenRequest.UserAgent = Http.ChromeUserAgent();
         tokenResponse          = tokenRequest.Post(oAuthATUri, requestParams, false);
         result[0] = JSONSerializer.getValueOfJSONString("access_token", tokenResponse.ToString());
         result[1] = " " + JSONSerializer.getValueOfJSONString("user_id", tokenResponse.ToString());
     }
     return(result);
 }
Ejemplo n.º 2
0
        private static bool SolveRecaptchaChallenge(ref HttpResponse response, HttpRequest request, Uri uri, string retry,
                                                    DLog log, CancellationToken cancelToken)
        {
            log?.Invoke($"{LogPrefix}Solving Recaptcha Challenge for URL: {uri.AbsoluteUri} ...");

            if (request.CaptchaSolver == null)
            {
                throw new CloudflareException($"{nameof(HttpRequest.CaptchaSolver)} required");
            }

            string respStr = response.ToString();
            string siteKey = respStr.Substring("data-sitekey=\"", "\"")
                             ?? throw new CloudflareException("Value of \"data-sitekey\" not found");

            string s = respStr.Substring("name=\"s\" value=\"", "\"")
                       ?? throw new CloudflareException("Value of \"s\" not found");

            string rayId = respStr.Substring("data-ray=\"", "\"")
                           ?? throw new CloudflareException("Ray Id not found");

            string answer = request.CaptchaSolver.SolveRecaptcha(uri.AbsoluteUri, siteKey, cancelToken);

            cancelToken.ThrowIfCancellationRequested();

            var rp = new RequestParams {
                ["s"]  = s,
                ["id"] = rayId,
                ["g-recaptcha-response"] = answer
            };

            string bfChallengeId = respStr.Substring("'bf_challenge_id', '", "'");

            if (bfChallengeId != null)
            {
                rp.Add(new KeyValuePair <string, string>("bf_challenge_id", bfChallengeId));
                rp.Add(new KeyValuePair <string, string>("bf_execution_time", "4"));
                rp.Add(new KeyValuePair <string, string>("bf_result_hash", string.Empty));
            }

            response = request.ManualGet(new Uri(uri, "/cdn-cgi/l/chk_captcha"), uri, rp);

            return(IsChallengePassed("ReCaptcha", ref response, request, uri, retry, log));
        }
Ejemplo n.º 3
0
        public static TransactionResult GetTransactionResult(string txHash)
        {
            var pars = new RequestParams();

            pars.Add("txHash", txHash);

            var response = RPCCall <TransactionResult>(IcxMethods.icx_getTransactionResult, pars).Result.Result;

            return(response);
        }
Ejemplo n.º 4
0
        public static ICXBlock GetBlockByHeight(long height)
        {
            string hexValue = height.ToString("X");

            var pars = new RequestParams();

            pars.Add("height", "0x" + hexValue.ToLower());

            var response = RPCCall <ICXBlock>(IcxMethods.icx_getBlockByHeight, pars).Result.Result;

            return(response);
        }
Ejemplo n.º 5
0
        public static RequestParams ConvertToRequestParams(List <ParserInputData> inputs, List <string> excludeKeys = null)
        {
            var formParams = new RequestParams();

            foreach (var input in inputs)
            {
                if (excludeKeys != null && excludeKeys.IndexOf(input.name) != -1)
                {
                    continue;
                }

                string valParam = input.value;
                string keyParam = input.name;

                formParams.Add(new KeyValuePair <string, string>(keyParam, valParam));
            }

            return(formParams);
        }
Ejemplo n.º 6
0
 public void SetRequestParam(string name, string value)
 {
     RequestParams.Add(name, value);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Проверка обновлений программы
        /// </summary>
        /// <param name="progVer">Текущая версия основного ПО</param>
        /// <param name="sldVer">Текущая версия библиотек</param>
        private void CheckUpdateProgram(string progVer, string sldVer)
        {
            int ver0, ver1, rev0, rev1;

            string[] vers = progVer.Split('.');

            RequestSettings reqSettings = new RequestSettings();
            reqSettings.Site = "http://it-planets.ru/mbstudio/download_info.php";
            RequestParams reqParams = new RequestParams();
            reqParams.Add("type_info", "ver_po,ver_sld");
            reqSettings.PostData = reqParams.ToString();
            SiteConnector connector = new SiteConnector(reqSettings);

            string newversion_info = string.Empty;
            try
            {
                 connector.DownLoad("GET", Encoding.UTF8);

                if (vers.Count() == 4)
                {
                    if (int.TryParse(vers[0], out ver0))
                    {

                    }
                }
            }
            catch(System.Net.WebException ex)
            {

            }
            catch(Exception ex)
            {

            }
        }