DTcms.API/DTcms.API.Weixin.Common/CRMComm.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using DTcms.BLL;
using DTcms.Model;
using Senparc.Weixin.MP.AdvancedAPIs;
using Senparc.Weixin.MP.CommonAPIs;
using Senparc.Weixin.MP.Entities;
using System;
using System.Collections.Generic;
namespace DTcms.API.Weixin.Common
{
public class CRMComm
{
private DTcms.BLL.weixin_access_token tokenBLL = new DTcms.BLL.weixin_access_token();
private DTcms.BLL.weixin_account accountBLL = new DTcms.BLL.weixin_account();
public string GetAccessToken(int accountId, out string error)
{
string access_token = string.Empty;
error = string.Empty;
string result2;
try
{
DTcms.Model.weixin_account accountModel = this.accountBLL.GetModel(accountId);
if (string.IsNullOrEmpty(accountModel.appid) || string.IsNullOrEmpty(accountModel.appsecret))
{
error = "AppId或者AppSecret未填写,请在补全信息!";
result2 = string.Empty;
return result2;
}
if (!this.tokenBLL.ExistsAccount(accountId))
{
AccessTokenResult result = CommonApi.GetToken(accountModel.appid, accountModel.appsecret, "client_credential");
access_token = result.access_token;
this.tokenBLL.Add(accountId, access_token);
result2 = access_token;
return result2;
}
DTcms.Model.weixin_access_token tokenModel = this.tokenBLL.GetAccountModel(accountId);
double chajunSecond = (System.DateTime.Now - tokenModel.add_time).TotalSeconds;
if (string.IsNullOrEmpty(tokenModel.access_token) || chajunSecond >= (double)tokenModel.expires_in)
{
AccessTokenResult result = CommonApi.GetToken(accountModel.appid, accountModel.appsecret, "client_credential");
access_token = result.access_token;
tokenModel.access_token = access_token;
tokenModel.add_time = System.DateTime.Now;
this.tokenBLL.Update(tokenModel);
}
else
{
access_token = tokenModel.access_token;
}
}
catch (System.Exception ex)
{
error = "获取AccessToken出错:" + ex.Message;
}
result2 = access_token;
return result2;
}
后面还有 78 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。