本文整理汇总了C#中HttpHelper.Post方法的典型用法代码示例。如果您正苦于以下问题:C# HttpHelper.Post方法的具体用法?C# HttpHelper.Post怎么用?C# HttpHelper.Post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpHelper
的用法示例。
在下文中一共展示了HttpHelper.Post方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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));
}
}
}
示例3: 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();
}
示例4: 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();
}
示例5: AddTemplateToAccount
private static void AddTemplateToAccount(string apikey, string templateContent)
{
var reader = new JsonReader();
dynamic template = reader.Read(templateContent);
var httpHelper = new HttpHelper();
if (!string.IsNullOrWhiteSpace(apikey))
{
//make sure to rewrite everything to the name
string name = template.name;
template.key = apikey;
template.slug = name;
var addResponse = httpHelper.Post(Mandrillurl + "/templates/add.json", template).Result;
Console.WriteLine(string.Format("Template add result {0}: {1} - {2}", template.slug, addResponse.Code, addResponse.StatusDescription));
}
}
示例6: Publish
/// <summary>
/// Authenticates against the service for this publish only.
/// </summary>
/// <param name="email">Tumblr account email address</param>
/// <param name="password">Tumblr account password</param>
public TumblrResult Publish(string email, string password, string group)
{
var postItems = new Dictionary<string, string>(GetPostItemsInternal());
postItems.Add(PostItemParameters.Email, email);
postItems.Add(PostItemParameters.Password, password);
postItems.Add(PostItemParameters.Generator, "TumblrAPI.NET");
if (!string.IsNullOrEmpty(group)) postItems.Add(PostItemParameters.Group, group);
var request = new HttpHelper(Settings.Default.API_URL, postItems);
var result = request.Post();
int postId;
if (result.PostStatus == PostStatus.Created
&& int.TryParse(result.Message, out postId))
{
PostId = postId;
}
return result;
}
示例7: GetTemplatesFromAccount
private static IDictionary<string, string> GetTemplatesFromAccount(string apikey,
string templateName = null, bool ignoreDates = false)
{
var templatesInAccount= new Dictionary<string,string>();
var reader = new JsonReader();
var httpHelper = new HttpHelper();
var templatesResponse = httpHelper.Post(Mandrillurl + "/templates/list.json", new { key = apikey }).Result;
if (templatesResponse.Code == HttpStatusCode.OK)
{
//
dynamic templates = reader.Read(templatesResponse.Body);
foreach (var t in templates)
{
if (!string.IsNullOrWhiteSpace(templateName)
&& !templateName.Equals(t.name, StringComparison.OrdinalIgnoreCase))
{
//this seems to be the only way to get single template by name (not slug!)
continue;
}
Console.WriteLine("Found template: " + t.name + " - " + t.slug);
//if templates are exported to source control and imported into other accounts
//it is usefull to strip out dates; otherwise they will be seen as an update to the file
//and you end it endless loops of updating accounts.
if (ignoreDates)
{
if (HasProperty(t, "published_at")) t.published_at = "2015-01-01 10:10:10";
if (HasProperty(t, "created_at")) t.created_at = "2015-01-01 10:10:10";
if (HasProperty(t, "updated_at")) t.updated_at = "2015-01-01 10:10:10";
if (HasProperty(t, "draft_updated_at")) t.draft_updated_at = "2015-01-01 10:10:10";
}
templatesInAccount.Add(t.name, ToJsonPrettyPrint(t));
}
}
return templatesInAccount;
}
示例8: Push
/// <summary>
/// 推送消息
/// </summary>
/// <param name="msg"></param>
/// <returns></returns>
public BasicResult Push(PushMessage msg)
{
var hh = new HttpHelper(Url);
return hh.Post<BasicResult>(msg.ToString(), new FormData { { "access_token", AccessToken } });
}