以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 其中一个公众号回复消息有异常(提供的服务出现故障,稍后再试),同样的代码其他公众号没有问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=116498) |
-- 作者:fubblyc -- 发布时间:2018/3/25 20:20:00 -- 其中一个公众号回复消息有异常(提供的服务出现故障,稍后再试),同样的代码其他公众号没有问题 同样的代码,别的公众号正常,其中一个公众号先回复 该公众号提供的服务出现故障,请稍后再试 。 然后继续正常回复设定的内容。 自定义菜单的关键词回复不会,正常,手动输入的关键词回复会这样。 带参数的二维码,关注事件的正常,关注后扫描的进去同样的故障情况。 其他公众号不会,就这个公众号会。 检查了这个公众号的配置,和其他的都一样,没有什么区别。 这个公众号有使用凡科的第三方平台,但是在今天之前都是正常的,就今天出现了这个问题。 折腾了一天了,没找到原因。 httprequest代码: Select Case e.Path Case "wxfwq","antaguangxi","antananjing" If Functions.Execute("VerifySignature",e) = False Then \'如果验证失败,直接返回 Return End If If e.Request.HttpMethod = "GET" If Functions.Execute("VerifySignature",e) Then e.WriteString(e.GetValues("echostr")) End If End If If e.path = "wxfwq" Then SaveConfigValue("zhangtao", "A公众号") ElseIf e.path = "antaguangxi" Then SaveConfigValue("zhangtao", "B公众号") ElseIf e.path = "antananjing" Then SaveConfigValue("zhangtao", "C公众号") End If Functions.Execute("wxjichu",e) wxjichu 自定义函数代码: Dim e As RequestEventArgs = args(0) Dim zhangtao As String = GetConfigValue("zhangtao","") If e.Request.HttpMethod = "Post" Dim xo As XObject = XObject.Parse(e.PlainText) Dim st As New Date(1970,1,1,8,0,0) selec t Case xo("MsgType") Case "event" \'如果是事件 \'Dim key As String = xo("EventKey") selec t Case xo("Event") Case "subscribe" \'关注事件 正常 Dim url As String = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN" url = CExp(url, Functions.Execute("GetAccessToken",zhangtao), xo("fro mUserName")) Dim hc As New HttpClient(url) Dim jo As JObject = Jobject.Parse(hc.GetDaTa) If jo("errcode") IsNot Nothing Then \'这里编写代码记录错误信息,方便查阅 Else Dim dr As DataRow = DataTables("WXUsers2").sq lAddNew() Dim nms() As String = {"openid","nickname","sex","city","country","province","headimgurl","groupid","remark","language"} For Each nm As String In nms dr(nm) = jo(nm) Next dr("subscribe_time") = Date.Now() dr("账套") = zhangtao dr.Save() Dim eKey As String = xo("EventKey") If eKey IsNot Nothing AndAlso eKey.StartsWith("qrscene_")Then \'判断是否是通过扫描二维码关注 Dim ticket As String = xo("Ticket") \'获取二维码的ticket Dim sceneid As String = eKey.SubString(8) \'获取二维码的情景ID,排除前缀qrscene_ If sceneid = 20180320 Then Dim joka As New JObject joka("touser") = xo("fro mUserName") joka("msgtype") = "wxcard" joka("wxcard") = New JObject joka("wxcard")("card_id") = "pI4erjsQEu_-5vTmxLfl_c11PBPE" Dim URLka As String = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}" Dim hcka As New HttpClient(CExp(URLka, Functions.Execute("GetAccessToken",zhangtao))) hcka.Content = joka.ToString() joka = JObject.Parse(hcka.GetData()) End If End If End If Case "SCAN" \'同样的问题 Dim ticket As String = xo("Ticket") \'获取二维码的ticket Dim sceneid As String = xo("EventKey") \'获取二维码的情景ID \'被动回复消息 If sceneid = 20180320 Then Dim joka As New JObject joka("touser") = xo("fro mUserName") joka("msgtype") = "wxcard" joka("wxcard") = New JObject joka("wxcard")("card_id") = "pI4erjsQEu_-5vTmxLfl_c11PBPE" Dim URLka As String = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}" Dim hcka As New HttpClient(CExp(URLka, Functions.Execute("GetAccessToken",zhangtao))) hcka.Content = joka.ToString() joka = JObject.Parse(hcka.GetData()) End If Case "CLICK" \'普通单击事件 正常 Dim drs As List(of DataRow) = DataTables("关键词回复").sq lselec t("账套 = \'" & zhangtao & "\' and 关键词 = \'" & xo("EventKey").Tostring & "\'") For Each dr1 As DataRow In drs If dr1("文本消息选") = True Then Dim joka As New JObject joka("touser") = xo("fro mUserName") joka("msgtype") = "text" joka("text") = New JObject joka("text")("content") = dr1("文本消息内容").Tostring Dim urlka As String = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}" Dim hcka As New HttpClient(CExp(urlka, Functions.Execute("GetAccessToken",zhangtao))) hcka.Content = joka.ToString() joka = JObject.Parse(hcka.GetData()) End If Next End selec t Case "text","image","voice","video","shortvideo" 不正常 If DataTables("Message").sq lFind("MsgID = \'" & xo("MsgId").ToString() & "\' and 账套 = \'" & zhangtao & "\' ") IsNot Nothing Then \'如果有相同MsgID的信息直接返回 Return "" End If Dim dr As DataRow = DataTables("Message").sq lAddNew() dr("CreateTime") = st.AddSeconds(xo("CreateTime")) Dim nms() As String = {"fro mUserName","MsgType","MsgId","Content","MediaId","ThumbMediaId","PicUrl","Format","Recognition"} For Each nm As String In nms dr(nm) = xo(nm) Next dr("账套") = zhangtao dr.Save() If xo("MsgType") = "text" Then e.WriteString("success") Dim drs As List(of DataRow) = DataTables("关键词回复").sq lselec t("账套 = \'" & zhangtao & "\' and 关键词 = \'" & xo("Content").ToString & "\' and 匹配方式 = \'完全匹配\'") Dim n As Integer = drs.Count If n > 0 Then For Each dr1 As DataRow In drs If dr1("文本消息选") = True Then Dim joka As New JObject joka("touser") = xo("fro mUserName") joka("msgtype") = "text" joka("text") = New JObject joka("text")("content") = dr1("文本消息内容").Tostring Dim urlka As String = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}" Dim hcka As New HttpClient(CExp(urlka, Functions.Execute("GetAccessToken",zhangtao))) hcka.Content = joka.ToString() joka = JObject.Parse(hcka.GetData()) End If Next End If Dim drs1 As List(of DataRow) = DataTables("关键词回复").sq lselec t("账套 = \'" & zhangtao & "\' and 关键词 like \'%" & xo("Content").ToString & "%\' and 匹配方式 = \'模糊匹配\'") Dim n1 As Integer = drs1.Count If n1 > 0 Then For Each dr1 As DataRow In drs1 If dr1("文本消息选") = True Then Dim joka As New JObject joka("touser") = xo("fro mUserName") joka("msgtype") = "text" joka("text") = New JObject joka("text")("content") = dr1("文本消息内容").Tostring Dim urlka As String = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}" Dim hcka As New HttpClient(CExp(urlka, Functions.Execute("GetAccessToken",zhangtao))) hcka.Content = joka.ToString() joka = JObject.Parse(hcka.GetData()) End If Next End If If n<1 And n1 < 1 Then Dim joka As New JObject joka("touser") = xo("fro mUserName") joka("msgtype") = "text" joka("text") = New JObject joka("text")("content") = "更多内容,请点击菜单栏了解详情!" Dim urlka As String = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}" Dim hcka As New HttpClient(CExp(urlka, Functions.Execute("GetAccessToken",zhangtao))) hcka.Content = joka.ToString() joka = JObject.Parse(hcka.GetData()) End If End If End selec t End If
[此贴子已经被作者于2018/3/25 20:22:07编辑过]
|
-- 作者:有点甜 -- 发布时间:2018/3/25 20:51:00 -- 不能及时在5秒内回复的情况下,就会出现这种问题。百度一下解决
你sqlfind、sqlselect等操作,都很耗时的吧?还有就是多用户使用的时候,更会出问题。 |
-- 作者:fubblyc -- 发布时间:2018/3/25 21:19:00 -- 甜老师,不用sqlfind 和 selec t ,有什么其他建议和方法呢 |
-- 作者:有点甜 -- 发布时间:2018/3/25 23:20:00 -- 以下是引用fubblyc在2018/3/25 21:19:00的发言:
甜老师,不用sqlfind 和 selec t ,有什么其他建议和方法呢
因为foxtable是直接操作表格数据的,把全部数据加载出来,直接find、select、addnew试试。
再有就是,foxtable那里执行的代码的耗时,是多少?有没有计算过? |
-- 作者:fubblyc -- 发布时间:2018/4/7 22:24:00 -- 好!!谢谢甜老师!! |