public string InstallNotify() { string authCode = Request["auth_code"]; int storeId = WebHelper.GetQueryInt("storeid", 0); //获取ticket var ticket = SuiteTicketManager.GetSuiteTicket(2); //获取套餐凭证 var suiteToken = BossHelper.Get_Suite_Token(ticket.SuiteTicket); //获取永久授权码以及授权信息 var pCode = WorkWeiXinSDK.Get_Permanent_Code(authCode, suiteToken); var agent_info = pCode.auth_info.Agent[0]; var auth_corp = pCode.auth_corp_info; var model = new PermanentCodeInfo() { StoreId = storeId, permanent_code = pCode.permanent_code, //永久授权码 access_token = pCode.access_token, //企业的access_token last_expires = DateTime.Now, //access_token 的获取时间 agentid = agent_info.agentid, app_name = agent_info.name, corpid = auth_corp.corpid, corp_full_name = auth_corp.corp_full_name, AddTime = DateTime.Now }; PermanentCodeManager.Add(model); Redirect(WorkContext.MallConfig.SiteUrl); return(string.Empty); }
public void InstallNotifyByUser() { string authCode = Request["auth_code"]; int storeId = WebHelper.GetQueryInt("storeid", 0); //获取ticket var ticket = SuiteTicketManager.GetSuiteTicket(1); //获取套餐凭证 Suite_Token suiteToken = UserHelper.Get_Suite_Token(ticket.SuiteTicket); //获取永久授权码以及授权信息 PermanentCode pCode = WorkWeiXinSDK.Get_Permanent_Code(authCode, suiteToken); Agent_Info agent_info = pCode.auth_info.Agent[0]; Auth_Corp_Info auth_corp = pCode.auth_corp_info; var model = new PermanentCodeInfo() { StoreId = storeId, permanent_code = pCode.permanent_code, //永久授权码 access_token = pCode.access_token, //企业的access_token last_expires = DateTime.Now, //access_token 的获取时间 agentid = agent_info.agentid, app_name = agent_info.name, corpid = auth_corp.corpid, corp_full_name = auth_corp.corp_full_name, AddTime = DateTime.Now }; PermanentCodeManager.Add(model); }