/// <summary> /// 获取授权帐号信息 /// </summary> /// <returns></returns> public string GetAuth(string authorizerAppid) { try { var authInfo = InterfaceApi.Get_authorizer_info(WeixinInfo.component_tokenInfo, authorizerAppid); return(authInfo.authorization_info.appid); } catch (Exception ex) { return("GetAuth:" + ex.Message + ex.ToString()); } }
//授权回调事件 获取公众号信息 // GET: /Receive/ public string Callback(string auth_code, string expires_in) { try { FileHelper.LogToTxt("WeixinInfo.component_tokenInfo: " + WeixinInfo.component_tokenInfo); var authInfo = InterfaceApi.Query_auth(WeixinInfo.component_tokenInfo, auth_code); WeixinInfo.authorizer_appid = authInfo.authorization_info.authorizer_appid; FileHelper.LogToTxt("Callback authorizer_appid: " + authInfo.authorization_info.authorizer_appid); return(GetAuth(authInfo.authorization_info.authorizer_appid)); } catch (Exception ex) { return(ex.Message + ex.StackTrace.ToString()); } }
/// <summary> /// 接收微信推送事件的消息方法 /// </summary> /// <param name="postModel"></param> /// <returns></returns> //[HttpPost] public string Sysmessage(PostModel postModel) { try { var msg = InterfaceApi.Component_verify_ticket(postModel, Request.InputStream); if (msg.InfoType == ThirdPartyInfo.component_verify_ticket.ToString()) { FileHelper.LogToTxt("msg.ComponentVerifyTicket:" + msg.ComponentVerifyTicket); //存储ticket WeixinInfo.componentVerifyTicket = msg.ComponentVerifyTicket; } else if (msg.InfoType == ThirdPartyInfo.unauthorized.ToString()) { //取消事件 todo } return("success"); } catch (Exception ex) { FileHelper.LogToTxt(ex.Message + ex.StackTrace.ToString()); return("success"); } }