当前位置: 首页>>代码示例>>C#>>正文


C# HttpHelper类代码示例

本文整理汇总了C#中HttpHelper的典型用法代码示例。如果您正苦于以下问题:C# HttpHelper类的具体用法?C# HttpHelper怎么用?C# HttpHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpHelper类属于命名空间,在下文中一共展示了HttpHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FakeLinkService

 public static ILinkService FakeLinkService()
 {
     ILinkRepository linkRepository = FakeLinkRepository();
     ILinkCrawlerService linkCrawler = FakeLinkCrawler();
     HttpHelper httpHelper = new HttpHelper();
     return new LinkService(linkRepository, linkCrawler, httpHelper);
 }
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:7,代码来源:MockHelpers.cs

示例2: PostProcessPayment

        public void PostProcessPayment(PaymentInfo order)
        {
            string PUB32 = "30819c300d06092a864886f70d010101050003818a003081860281807cd21042439755abab54981724a366a66913258fcbc6075555e973d48137e22eedd5ab5f3be57404a30795e71f6f4c8f31d4715e3e0d1985426ed51c131bee24448202f3c777558c0e5b23cac643a5bed52719fef620548c6608377d5a86fd57cb8cb67272656cbd9dd8d796dc5613400edb1905b7802a7e7bcd673c3d23d3bf020111";//公钥前30位 新接口使用
            string MERCHANTID = "105584073990057";                  //商户代码(客户号)
            string POSID = "100000631";                             //商户柜台代码
            string BRANCHID = "442000000";                          //分行代码
            string ORDERID = order.SysOrderNo;                      //定单号
            string PAYMENT = order.OrderAmount;                     //付款金额 
            string MAC = "MERCHANTID=" + MERCHANTID + "&POSID=" + POSID
                       + "&BRANCHID=" + BRANCHID + "&ORDERID=" + ORDERID
                       + "&PAYMENT=" + PAYMENT + "&CURCODE=01"
                       + "&TXCODE=520100" + "&REMARK1="
                       + "&REMARK2=";

            HttpHelper http = new HttpHelper();
            http.Url = order.PayOnlineProviderUrl;
            http.Add("INTER_FLAG", "0");                            //商户接口类型 0为旧接口,1为新接口
            http.Add("MERCHANTID", MERCHANTID);
            http.Add("POSID", POSID);
            http.Add("BRANCHID", BRANCHID);
            http.Add("PUB32", PUB32);
            http.Add("ORDERID", ORDERID);
            http.Add("PAYMENT", PAYMENT);                           //付款金额 
            http.Add("CURCODE", "01");                              //币种缺省为01-人民币 
            http.Add("TXCODE", "520100");                           //交易码
            http.Add("REMARK1", "");                                //备注1
            http.Add("REMARK2", "");                                //备注2
            http.Add("DOTYPE", "0");                                //支付类型 0为网上银行支付,1为E付卡支付
            http.Add("MAC", PayHelper.GetMD5(MAC, "").ToLower());   //MAC校验域
            http.Post();
        }
开发者ID:aNd1coder,项目名称:Wojoz,代码行数:31,代码来源:CcbPaymentProcessor.cs

示例3: GetSearchModels

        private SearchModels GetSearchModels(string postdata)
        {
            HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://search.jiayuan.com/v2/search_v2.php",//URL     必需项
                Method = "Post",//URL     可选项 默认为Get
                Timeout = 100000,//连接超时时间     可选项默认为100000
                ReadWriteTimeout = 30000,//写入Post数据超时时间     可选项默认为30000
                IsToLower = false,//得到的HTML代码是否转成小写     可选项默认转小写
                Cookie = "",
                UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36",//用户的浏览器类型,版本,操作系统     可选项有默认值
                Accept = "text/html, application/xhtml+xml, */*",//    可选项有默认值
                ContentType = "application/x-www-form-urlencoded; charset=UTF-8",
                Postdata = postdata,
            };
            HttpResult result = http.GetHtml(item);
            string html = result.Html;

            var json = html.Replace("##jiayser##", "").Replace(@"##jiayser##//", "");
            json = json.Substring(0, json.Length - 2);
            JavaScriptSerializer jss = new JavaScriptSerializer();
            var list = jss.Deserialize(json, typeof(SearchModels)) as SearchModels;
            list.userInfo.ForEach(x=> {
                x.randTag = System.Web.HttpUtility.HtmlDecode(x.randTag);
                x.randListTag = System.Web.HttpUtility.HtmlDecode(x.randListTag);
                x.matchCondition = System.Web.HttpUtility.HtmlDecode(x.matchCondition);
                x.shortnote = System.Web.HttpUtility.HtmlDecode(x.shortnote);
            });
            return list;
        }
开发者ID:niubileme,项目名称:Love-JY,代码行数:31,代码来源:HomeController.cs

示例4: Button1_Click

 protected void Button1_Click(object sender, EventArgs e)
 {
     //提交的底层方法!!!
     string u = url.Text.Trim();
     string d = data.Text.Trim();
     HttpHelper http = new HttpHelper();
     HttpItem item = new HttpItem()
     {
         URL =u,//URL     必需项
         Method = "post",//URL     可选项 默认为Get
         IsToLower = false,//得到的HTML代码是否转成小写     可选项默认转小写
         Cookie = "",//字符串Cookie     可选项
         Referer = "",//来源URL     可选项
         Postdata = d.ToString(),//Post数据     可选项GET时不需要写
         PostEncoding =Encoding.UTF8 ,
         Timeout = 100000,//连接超时时间     可选项默认为100000
         ReadWriteTimeout = 30000,//写入Post数据超时时间     可选项默认为30000
         UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
         ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值
         Allowautoredirect = true,//是否根据301跳转     可选项
         //CerPath = "d:\123.cer",//证书绝对路径     可选项不需要证书时可以不写这个参数
         //Connectionlimit = 1024,//最大连接数     可选项 默认为1024
         ProxyIp = "",//代理服务器ID     可选项 不需要代理 时可以不设置这三个参数
         ResultType = ResultType.String
     };
     HttpResult result = http.GetHtml(item);
     res.Text = result.Html;
 }
开发者ID:aj-hc,项目名称:SY,代码行数:28,代码来源:WebTest1.aspx.cs

示例5: PostProcessPayment

        public void PostProcessPayment(PaymentInfo order)
        {
            DateTime datatime = DateTime.Now;
            string v_hms = datatime.ToString("HHmmss", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            string v_ymd = datatime.ToString("yyyyMMdd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            string v_mid = "1204790601";
            string payOnlineKey = "a75ee55ded934c96968f747c809005b9";
            string v_oid = order.SysOrderNo;
            string v_url = order.ResultNotifyURL;
            Random rnd = new Random();
            int Sequence = (v_oid.Substring(v_oid.Length - 10, 10)).ToInt() + rnd.Next(1, 9);//序列号,保证唯一性
            string transaction_id = v_mid + v_ymd + Sequence;
            string amount = decimal.Round(order.OrderAmount.ToDecimal() * 100, 0) + "";
            string md5string = PayHelper.GetMD5("cmdno=1&date=" + v_ymd + "&bargainor_id=" + v_mid
                         + "&transaction_id=" + transaction_id + "&sp_billno=" + v_oid
                         + "&total_fee=" + amount + "&fee_type=1&return_url=" + v_url
                         + "&attach=my_magic_string&key=" + payOnlineKey, "");

            HttpHelper http = new HttpHelper();
            http.Url = order.PayOnlineProviderUrl;
            http.Add("cmdno", "1");                         //业务代码,1表示支付
            http.Add("date", v_ymd);                        //商户日期
            http.Add("bank_type", "0");                     //银行类型:财付通,0
            http.Add("desc", v_oid);                        //交易的商品名称
            http.Add("purchaser_id", "");                   //用户(买方)的财付通帐户,可以为空
            http.Add("bargainor_id", v_mid);                //商家的商户号
            http.Add("transaction_id", transaction_id);     //交易号(订单号)
            http.Add("sp_billno", v_oid);                   //商户系统内部的订单号
            http.Add("total_fee", amount);                  //总金额,以分为单位
            http.Add("fee_type", "1");                      //现金支付币种,1人民币
            http.Add("return_url", v_url);                  //接收财付通返回结果的URL
            http.Add("attach", "attachmy_magic_string");          //商家数据包,原样返回
            http.Add("sign", md5string);                    //MD5签名     
            http.Post();
        }
开发者ID:aNd1coder,项目名称:Wojoz,代码行数:35,代码来源:TencentPaymentProcessor.cs

示例6: HandleProecssInfo

 /// <summary>
 /// 获取快递进度信息
 /// </summary>
 /// <returns>是否处理成功</returns>
 public static bool HandleProecssInfo(string ProxyIp)
 {
     List<ExpressInfo> listExpressInfo = GetAllExpressInfo();
     HttpHelper http = new HttpHelper();
     string url = string.Empty;
     string html = string.Empty;
     int SuccessCount = 0;
     foreach (var ExpressInfo in listExpressInfo)
     {
         try
         {
             //进度查询URL
             url = string.Format("http://www.kuaidi100.com/query?type={0}&postid={1}&id=1&valicode=&temp=0.7078260387203143", ExpressInfo.ExpressCompanyCode, ExpressInfo.ExpressNo);
             html = GetHTML(url, ProxyIp);
             if (html == null)
             {
                 TaskLog.ExpressProgressLogInfo.WriteLogE(string.Format("url:{0},ip:{1}获取快递进度内容出错", url, ProxyIp));
                 continue;
             }
             TaskLog.ExpressProgressLogInfo.WriteLogE(string.Format("开始查询快递单号{0}进度信息", ExpressInfo.ExpressNo));
             if (ParseExpressInfo(html, ExpressInfo))
             {
                 SuccessCount++;
                 TaskLog.ExpressProgressLogInfo.WriteLogE(string.Format("结束快递单号{0}进度信息查询", ExpressInfo.ExpressNo));
             }
             //等待10s再次查询其它单号信息,避免间隔太小ip被封
             Thread.Sleep(10000);
         }
         catch (Exception ex)
         {
             TaskLog.ExpressProgressLogError.WriteLogE(string.Format("url:{0},ip:{1}获取快递进度内容出错", url, ProxyIp), ex);
         }
     }
     return SuccessCount == listExpressInfo.Count;
 }
开发者ID:jiasw,项目名称:TaskManager,代码行数:39,代码来源:ExpressUtil.cs

示例7: AcquireLicenseReactively

        async public void  AcquireLicenseReactively(PlayReadyLicenseAcquisitionServiceRequest licenseRequest)
        {
            Exception exception = null;
            
            try
            {   
                _serviceRequest = licenseRequest;
                ConfigureServiceRequest();

                if( RequestConfigData.ManualEnabling )
                {
                    HttpHelper httpHelper = new HttpHelper( licenseRequest );
                    await httpHelper.GenerateChallengeAndProcessResponse();
                }
                else
                {
                    await licenseRequest.BeginServiceRequest();
                }
            }
            catch( Exception ex )
            {
                exception = ex;
            }
            finally
            {
                LAServiceRequestCompleted( licenseRequest, exception );
            }
        }
开发者ID:bondarenkod,项目名称:pf-arm-deploy-error,代码行数:28,代码来源:LicenseAcquisition.cs

示例8: BeforeFeature

        public static void BeforeFeature()
        {
            //_testServer = TestServer.Create(app =>
            //{
            //    var startup = new Startup();
            //    startup.Configuration(app);

            //    //var config = new HttpConfiguration();
            //    //WebApiConfig.Configure(config);

            //    //app.UseWebApi(config);
            //});

            TestUserManager.AddUserIfNotExists(TestUserName, TestPwd);

            _authApiTestServer = TestServer.Create<AuthServer.Startup>();
            _authApiHttpHelper = new HttpHelper(_authApiTestServer.HttpClient);
            var request = String.Format("grant_type=password&username={0}&password={1}", TestUserName, TestPwd);
            _bearerToken = _authApiHttpHelper.Post<AccessTokenResponse>("token", request).Token;

            _todoApiTestServer = TestServer.Create<Api.Startup>();
            _todoApiHttpHelper = new HttpHelper(_todoApiTestServer.HttpClient);

            SetToDoContextConnectionString();
        }
开发者ID:jbijlsma,项目名称:ToDo,代码行数:25,代码来源:ToDoSteps.cs

示例9: DeleteTemplates

        private static void DeleteTemplates(string apikey, DirectoryInfo backupDir, 
                                               string templateName = null)
        {
            var reader = new JsonReader();
            var httpHelper = new HttpHelper();

            //make backups.. always
            var templates = ExportTemplatesToFolder(apikey, backupDir, templateName);

            if (templates.Any())
            {

                foreach (var template in templates)
                {
                    //check if we wanted to delete a single template
                    if (!string.IsNullOrWhiteSpace(templateName)
                     && !templateName.Equals(template.Key, StringComparison.OrdinalIgnoreCase))
                    {
                        //this seems to be the only way to get single template by name (not slug!)
                        continue;
                    }

                    dynamic t = reader.Read(template.Value);

                    //delete, take slug and use as name
                    string name = t.slug;

                    var deleteTemplate = httpHelper.Post(Mandrillurl + "/templates/delete.json", new {key = apikey, name}).Result;

                    Console.WriteLine(string.Format("Template delete result {0}: {1} - {2}", name, deleteTemplate.Code, deleteTemplate.StatusDescription));
                }
            }
        }
开发者ID:henkmeulekamp,项目名称:MandrillBackupNet,代码行数:33,代码来源:Program.cs

示例10: SendAnalytics

        private void SendAnalytics(string FacebookAppId = null)
        {
            try
            {
                if (!AnalyticsSent)
                {
                    AnalyticsSent = true;

#if !(WINDOWS_PHONE)
                    Version assemblyVersion = typeof(FacebookSessionClient).GetTypeInfo().Assembly.GetName().Version;
#else                    
                    string assemblyVersion = Assembly.GetExecutingAssembly().FullName.Split(',')[1].Split('=')[1];
#endif
                    string instrumentationURL = String.Format("https://www.facebook.com/impression.php/?plugin=featured_resources&payload=%7B%22resource%22%3A%22microsoft_csharpsdk%22%2C%22appid%22%3A%22{0}%22%2C%22version%22%3A%22{1}%22%7D",
                            FacebookAppId == null ? String.Empty : FacebookAppId, assemblyVersion);

                    HttpHelper helper = new HttpHelper(instrumentationURL);

                    // setup the read completed event handler to dispose of the stream once the results are back
                    helper.OpenReadCompleted += (o, e) => { if (e.Error == null) using (var stream = e.Result) { }; };
                    helper.OpenReadAsync();
                }
            }
            catch { } //ignore all errors
        }
开发者ID:niyueming,项目名称:facebook-winclient-sdk,代码行数:25,代码来源:FacebookSessionClient.cs

示例11: CreateMenu

        /// <summary>
        ///     创建菜单
        /// </summary>
        /// <param name="menu"></param>
        /// <returns></returns>
        public BasicResult CreateMenu(Menu menu)
        {
            var hh = new HttpHelper(CreateUrl);
            var r = hh.Post<BasicResult>(menu.ToString(), new FormData {{"access_token", AccessToken}});

            return r;
        }
开发者ID:peidachang,项目名称:Weixin_api_.net,代码行数:12,代码来源:MenuHelper.cs

示例12: SendMessage

 /// <summary>
 /// 发送短信
 /// </summary>
 /// <param name="receiver">短信接收人手机号码</param>
 /// <param name="content">短信内容</param>
 /// <returns>发送状态</returns>
 public static SMSCode SendMessage(string receiver, string content)
 {
     try
     {
         //创建Httphelper对象
         HttpHelper http = new HttpHelper();
         //创建Httphelper参数对象
         HttpItem item = new HttpItem()
         {
             URL = string.Format("{0}?phone={1}&content=验证码:{2}", SmsAPI, receiver, content),//URL     必需项    
             Method = "get",//可选项 默认为Get   
             ContentType = "text/plain"//返回类型    可选项有默认值 ,
         };
         item.Header.Add("apikey", Apikey);
         //请求的返回值对象
         HttpResult result = http.GetHtml(item);
         JObject jo = JObject.Parse(result.Html);
         JToken value = null;
         if (jo.TryGetValue("result", out value))
         {
             return EnumHelper.IntToEnum<SMSCode>(Convert.ToInt32(value.ToString()));
         }
         return SMSCode.SystemBusy;
     }
     catch (Exception ex)
     {
         LogHelper.WriteLog("短信发送失败", ex);
         return SMSCode.Exception;
     }
 }
开发者ID:jiasw,项目名称:TaskManager,代码行数:36,代码来源:SmsHelper.cs

示例13: Reddit

 public Reddit()
 {
     _httpHelper = new HttpHelper();
     API_DELAY = int.Parse(ConfigurationManager.AppSettings["APIDelay"]);
     CACHE_DIRECTORY = ConfigurationManager.AppSettings["CacheDirectory"];
     _timeOfLastAPIRequest = null;
     _retrievedComments = new List<string>();
 }
开发者ID:faintpixel,项目名称:SketchDaily-ParticipationTracker,代码行数:8,代码来源:Reddit.cs

示例14: QueryMenu

 /// <summary>
 /// 查询菜单
 /// </summary>
 /// <returns></returns>
 public Menu QueryMenu()
 {
     var hh = new HttpHelper(QueryUrl);
     var oo = new { menu = new Menu() };
     var or = hh.GetAnonymous(new FormData { { "access_token", AccessToken } }, oo);
     var r = or.menu;
     return r;
 }
开发者ID:236808388,项目名称:Weixin_api_.net,代码行数:12,代码来源:MenuHelper.cs

示例15: GetAccessTokenNoCache

        /// <summary>
        /// 获取每次操作微信API的Token访问令牌
        /// </summary>
        /// <param name="corpid">企业Id</param>
        /// <param name="corpsecret">管理组的凭证密钥</param>
        /// <returns></returns>
        public string GetAccessTokenNoCache(string corpid, string corpsecret)
        {
            var url = string.Format("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={0}&corpsecret={1}",
                                    corpid, corpsecret);

            HttpHelper helper = new HttpHelper();
            string result = helper.GetHtml(url);
            string regex = "\"access_token\":\"(?<token>.*?)\"";

            string token = CRegex.GetText(result, regex, "token");
            return token;
        }
开发者ID:ZhouAnPing,项目名称:Mail,代码行数:18,代码来源:WechatUtil.cs


注:本文中的HttpHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。