public override IResponseMessageBase OnTextRequest(RequestMessageText requestMessage) { if (requestMessage.Content == "TESTCOMPONENT_MSG_TYPE_TEXT") { var responseMessage = requestMessage.CreateResponseMessage <ResponseMessageText>(); responseMessage.Content = requestMessage.Content + "_callback";//固定为TESTCOMPONENT_MSG_TYPE_TEXT_callback return(responseMessage); } if (requestMessage.Content.StartsWith("QUERY_AUTH_CODE:")) { //使用数据库去记录 var _contextOptions = new DbContextOptionsBuilder <WechatOpenCoreDbContext>() .UseMySql("Server=120.79.31.209;Port=3336;Uid=root;Pwd=628VqB2sgJwLgOvngXQ3;Database=hchh;") .Options; string openTicket = hostingEnvironment.GetOpenTicket(componentAppId, _contextOptions); var query_auth_code = requestMessage.Content.Replace("QUERY_AUTH_CODE:", ""); try { var component_access_token = Senparc.Weixin.Open.ComponentAPIs.ComponentApi.GetComponentAccessToken(componentAppId, componentSecret, openTicket).component_access_token; var oauthResult = Senparc.Weixin.Open.ComponentAPIs.ComponentApi.QueryAuth(component_access_token, componentAppId, query_auth_code); //调用客服接口 var content = query_auth_code + "_from_api"; var sendResult = Senparc.Weixin.MP.AdvancedAPIs.CustomApi.SendText(oauthResult.authorization_info.authorizer_access_token, requestMessage.FromUserName, content); } catch (Exception ex) { throw; } } return(null); }