本文整理汇总了C#中ApiClient.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# ApiClient.Execute方法的具体用法?C# ApiClient.Execute怎么用?C# ApiClient.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiClient
的用法示例。
在下文中一共展示了ApiClient.Execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMenuTest
public static void CreateMenuTest(string weixinID)
{
MenuInfo firstButon1 = new MenuInfo();
firstButon1.type = MenuType.click.ToString();
firstButon1.name = "下一个笑话";
firstButon1.key = "V1001_HOT";
List<MenuInfo> button = new List<MenuInfo>();
button.Add(firstButon1);
string menuInfostr = JsonConvert.SerializeObject(new
{
button = button
});
CreateMenuRequest request = new CreateMenuRequest(menuInfostr, ApiAccessTokenManager.Instance.GetTokenByWeixinID(weixinID));
ApiClient client = new ApiClient();
var response = client.Execute(request);
if (!response.IsError)
{
Console.WriteLine(response.ToString());
}
else
{
Console.WriteLine(response.ErrorCode + ", " + response.ErrorMessage);
}
}
示例2: RefeshTicket
/// <summary>
/// 刷新ticket
/// </summary>
/// <param name="access_Token"></param>
private void RefeshTicket(string access_Token)
{
Dictionary<string, object> bugobjd = new Dictionary<string, object>();
try
{
bugobjd.Add("方法名", "刷新ticket");
bugobjd.Add("access_Token", access_Token);
// 更新ticket
GetTicketRequest ticketInfo = new GetTicketRequest(access_Token, "jsapi");
ApiClient client = new ApiClient();
DateTime now = DateTime.Now;
var ticketResponse = client.Execute(ticketInfo);
bugobjd.Add("ticketResponse", ticketResponse);
if (this.WeixinTicketDic == null)
{
this.WeixinTicketDic = new Dictionary<string, MTicketInfo>();
}
if (this.WeixinTicketDic.ContainsKey(access_Token))
{
this.WeixinTicketDic[access_Token].Ticket = ticketResponse.Ticket;
this.WeixinTicketDic[access_Token].OutTime = now.AddSeconds(ticketResponse.Expires_In);
}
else
{
this.WeixinTicketDic.Add(access_Token, new MTicketInfo()
{
Ticket = ticketResponse.Ticket,
Access_Token = access_Token,
OutTime = now.AddSeconds(ticketResponse.Expires_In)
});
}
bugobjd.Add("WeixinTicketDic", WeixinTicketDic);
}
catch (Exception ex)
{
TxtLogHelper.WriteLog_Day(new TxtLogInfoObject()
{
LogType = EnumLogType.Error,
LogMessage = string.Format(" 刷新ticket 错误信息{0};堆栈信息{1}", ex.Message, ex.StackTrace),
});
throw;
}
finally
{
TxtLogHelper.WriteDebugLog(bugobjd);
}
}