本文整理汇总了C#中HttpHelper类的典型用法代码示例。如果您正苦于以下问题:C# HttpHelper类的具体用法?C# HttpHelper怎么用?C# HttpHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpHelper类属于命名空间,在下文中一共展示了HttpHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: GetPage
public static string GetPage(string url)
{
var http = new HttpHelper();
var item = new HttpItem
{
URL = url,
Cookie = User.Cookie,
};
item.Header.Add("X-Requested-With", "XMLHttpRequest");
HttpResult result = http.GetHtml(item);
string html = result.Html;
return html;
}
开发者ID:Rozbo,项目名称:51ctohelper,代码行数:13,代码来源:DoHtml.cs
示例17: GetOnline
/// <summary>
/// 获取在线用户实例
/// </summary>
/// <returns>网页实例</returns>
public static string GetOnline()
{
var http = new HttpHelper();
var item = new HttpItem
{
URL = "http://home.51cto.com/index.php?s=/Friend/online/p/",
Cookie = User.Cookie,
};
item.Header.Add("X-Requested-With", "XMLHttpRequest");
HttpResult result = http.GetHtml(item);
string html = result.Html;
return html;
}
开发者ID:Rozbo,项目名称:51ctohelper,代码行数:17,代码来源:DoHtml.cs
示例18: Query
/// <summary>
/// 查询分组。
/// 失败时抛出WxException异常
/// </summary>
/// <returns></returns>
public WxGroupQueryResult Query()
{
var s = new HttpHelper(QueryUrl).GetString(new FormData
{
{"access_token", AccessToken}
});
var ret = JsonConvert.DeserializeObject<WxGroupQueryResult>(s);
if (ret.Groups == null)
throw new WxException(JsonConvert.DeserializeObject<BasicResult>(s));
return ret;
}
开发者ID:peidachang,项目名称:Weixin_api_.net,代码行数:18,代码来源:GroupManager.cs
示例19: 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 icbcAmount = decimal.Ceiling(order.OrderAmount.ToDecimal() * 100).ToString(); //订单金额,以分为单位
StringBuilder TranData = new StringBuilder();
TranData.Append("<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"no\"?>");
TranData.Append("<B2CReq>");
TranData.Append("<interfaceName>ICBC_PERBANK_B2C</interfaceName>"); //接口名
TranData.Append("<interfaceVersion>1.0.0.3</interfaceVersion>"); //版本号
TranData.Append("<orderInfo>");
TranData.Append("<orderDate>" + v_ymd + v_hms + "</orderDate>"); //交易日期时间格式为:YYYYMMDDHHmmss
TranData.Append("<orderid>" + order.SysOrderNo + "</orderid>"); //订单号
TranData.Append("<amount>" + icbcAmount + "</amount>"); //订单金额
TranData.Append("<curType>001</curType>"); //支付币种
TranData.Append("<merID>4000EC20001125</merID>"); //商户代码
TranData.Append("<merAcct>4000023819200132437</merAcct>"); //商户账号
TranData.Append("</orderInfo>");
TranData.Append("<custom>");
TranData.Append("<verifyJoinFlag>0</verifyJoinFlag>"); //检验联名标志
TranData.Append("<Language>ZH_CN</Language>"); //语言版本
TranData.Append("</custom>");
TranData.Append("<message>");
TranData.Append("<goodsID></goodsID>"); //商品编号
TranData.Append("<goodsName></goodsName>"); //商品名称
TranData.Append("<goodsNum></goodsNum>"); //商品数量
TranData.Append("<carriageAmt></carriageAmt>"); //已含运费金额
TranData.Append("<merHint></merHint>"); //商城提示
TranData.Append("<remark1></remark1>"); //备注字段1
TranData.Append("<remark2></remark2>"); //备注字段2
TranData.Append("<merURL>" + order.ResultNotifyURL + "</merURL>"); //返回商户URL
TranData.Append("<merVAR></merVAR>"); //返回商户变量
TranData.Append("</message>");
TranData.Append("</B2CReq>");
string tranData = TranData.ToString();
ICBCEBANKUTILLib.B2CUtil icbc = new ICBCEBANKUTILLib.B2CUtil();
int IcbcNew = icbc.init(HttpContext.Current.Server.MapPath("key/icbc/ICBC_Produce.crt"), HttpContext.Current.Server.MapPath("key/icbc/ICBC_Produce.crt"), HttpContext.Current.Server.MapPath("key/icbc/ICBC_Produce.key"), "12345679");
string Icbcsign = icbc.signC(tranData, tranData.Length);
string merCert = icbc.getCert(1);
tranData = PayHelper.Base64Code(tranData);
HttpHelper http = new HttpHelper();
http.Url = order.PayOnlineProviderUrl;
http.Add("interfaceName", "ICBC_PERBANK_B2C"); //接口名
http.Add("interfaceVersion", "1.0.0.3"); //版本号
http.Add("tranData", tranData); //交易数据
http.Add("merSignMsg", Icbcsign); //订单签名数据
http.Add("merCert", merCert); //商城公匙
http.Post();
}
开发者ID:aNd1coder,项目名称:Wojoz,代码行数:51,代码来源:IcbcPaymentProcessor.cs
示例20: GetFirstPageUserList
/// <summary>
/// 获取第一页(前10000用户)。
/// 如果需要更多,请使用回调。
/// </summary>
/// <returns></returns>
public WxUserListResult GetFirstPageUserList()
{
var s = new HttpHelper(UserListUrl).GetString(new FormData
{
{"access_token", AccessToken},
{"next_openid", string.Empty}
});
var ret = JsonConvert.DeserializeObject<WxUserListResult>(s);
if (ret.data == null)
throw new WxException(JsonConvert.DeserializeObject<BasicResult>(s));
return ret;
}
开发者ID:peidachang,项目名称:Weixin_api_.net,代码行数:19,代码来源:UserManager.cs
注:本文中的HttpHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论