Parcourir la source

GetWeixinWebaccess_token 日志记录

西昌缴费二期
liangkun il y a 2 ans
Parent
révision
46d22e489f
1 fichiers modifiés avec 36 ajouts et 23 suppressions
  1. +36
    -23
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/WeixinApi.cs

+ 36
- 23
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/WeixinApi.cs Voir le fichier

@@ -323,43 +323,56 @@ namespace Learun.Application.WebApi.Modules

public Response GetWeixinWebaccess_token(dynamic _)
{
var entity = weChatConfigIbll.GetEnableEntity();
string appid = entity?.APPId;
string secret = entity?.secret;
string url = Request.Query["url"];
var responsejson = HttpGet("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret);
if (!string.IsNullOrEmpty(responsejson))
try
{
var weixintokenobj = JsonConvert.DeserializeObject<dynamic>(responsejson);
if (string.IsNullOrEmpty(weixintokenobj.errcode))
var entity = weChatConfigIbll.GetEnableEntity();
string appid = entity?.APPId;
string secret = entity?.secret;
string url = Request.Query["url"];
string responsejson = HttpGet("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret);
//日志记录
LogEntity log = new LogEntity();
log.F_CategoryId = 123;
log.F_ExecuteResultJson = responsejson;
log.WriteLog();
if (!string.IsNullOrEmpty(responsejson))
{
string access_token = weixintokenobj.access_token;
string jsapi_ticket = HttpGet("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=" + access_token + "&type=jsapi");
var weixinjsapiticketobj = JsonConvert.DeserializeObject<dynamic>(jsapi_ticket);
if (weixinjsapiticketobj.errcode == 0)
var weixintokenobj = JsonConvert.DeserializeObject<dynamic>(responsejson);
if (string.IsNullOrEmpty(weixintokenobj.errcode))
{
string ticket = weixinjsapiticketobj.ticket;
//生成签名
string noncestr = Util.CommonHelper.CreateNo();
string timestamp = GetTimeStamp(true);
string param = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "&timestamp=" + timestamp + "&url=" + url;
string certificate = SHA1(param).ToLower();
return Success(new { appid, noncestr, timestamp, certificate });
string access_token = weixintokenobj.access_token;
string jsapi_ticket = HttpGet("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=" + access_token + "&type=jsapi");
var weixinjsapiticketobj = JsonConvert.DeserializeObject<dynamic>(jsapi_ticket);
if (weixinjsapiticketobj.errcode == 0)
{
string ticket = weixinjsapiticketobj.ticket;
//生成签名
string noncestr = Util.CommonHelper.CreateNo();
string timestamp = GetTimeStamp(true);
string param = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "&timestamp=" + timestamp + "&url=" + url;
string certificate = SHA1(param).ToLower();
return Success(new { appid, noncestr, timestamp, certificate });
}
else
{
return Fail("微信授权失败,请重试。" + weixinjsapiticketobj.errcode + weixinjsapiticketobj.errmsg);
}
}
else
{
return Fail("微信授权失败,请重试。" + weixinjsapiticketobj.errcode + weixinjsapiticketobj.errmsg);
return Fail("微信授权失败,请重试。" + weixintokenobj.errcode + weixintokenobj.errmsg);
}
}
else
{
return Fail("微信授权失败,请重试。" + weixintokenobj.errcode + weixintokenobj.errmsg);
return Fail("微信授权失败,请重试。");
}
}
else
catch (Exception e)
{
return Fail("微信授权失败,请重试。");
return Fail("微信授权失败,请重试。"+e.Message);
}
}

/// <summary>


Chargement…
Annuler
Enregistrer