|
|
|
@ -20,13 +20,23 @@ namespace BWP.B3WeChat.Utils |
|
|
|
|
|
|
|
static string token; |
|
|
|
|
|
|
|
|
|
|
|
static DateTime? getTokenTime; |
|
|
|
|
|
|
|
static readonly TimeSpan expiredSpan = new TimeSpan(2, 0, 0); |
|
|
|
static string TOKEN |
|
|
|
{ |
|
|
|
get |
|
|
|
{ |
|
|
|
if (getTokenTime.HasValue && ((TimeSpan)(DateTime.Now - getTokenTime.Value)) >= expiredSpan) |
|
|
|
{ |
|
|
|
token = string.Empty; |
|
|
|
} |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(token)) |
|
|
|
{ |
|
|
|
token = GetToken(); |
|
|
|
getTokenTime = DateTime.Now; |
|
|
|
} |
|
|
|
return token; |
|
|
|
} |
|
|
|
@ -90,7 +100,7 @@ namespace BWP.B3WeChat.Utils |
|
|
|
SendTemplateMessageResult result = new SendTemplateMessageResult(); |
|
|
|
MeassageBody body = new MeassageBody(); |
|
|
|
body.touser = openID; |
|
|
|
body.template_id = templateID; |
|
|
|
body.template_id = templateID; |
|
|
|
body.url = url; |
|
|
|
body.data = dic; |
|
|
|
string postData = jsonHelper.Serialize(body); |
|
|
|
|