以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]微信配置失败  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=106492)

--  作者:sjx71
--  发布时间:2017/9/10 10:14:00
--  [求助]微信配置失败

配置环境

一台笔记本,内网IP 192.168.255.59,端口映射到 111.*.*.*:80

项目中写了GetAccessTokenVerifySignature函数,改了APPID和开发者密钥

申请了微信测试号

url   http://111.*.*.*/wefox

token   foxtable

点提交 配置失败

定义菜单能够实现

关注之后,给公众号发送信息,message 表内没有任何显示

公众号主动发消息可以实现

 

可能是什么问题,还有什么需要注意的,请老师们帮着看一下

 

谢谢老师

 

HttpRequest事件代码

Dim fl As String = "d:\\web\\" & e.path

If filesys.FileExists(fl)

    Dim idx As Integer = fl.LastIndexOf(".")

    Dim ext As String  = fl.SubString(idx)

    Sel ect Case ext

        Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar"

            e.WriteFile(fl)

            Return \'这里必须返回

    End Sel ect

End If

 

Sel ect Case e.path

    Case "wefox"

        If e.Request.HttpMethod.ToUpper = "GET"

            If Functions.Execute("VerifySignature",e) Then

                e.WriteString(e.GetValues("echostr"))

            End If

        ElseIf e.Request.HttpMethod.ToUpper = "Post"

            Dim xo As XObject = XObject.Parse(e.PlainText)

            Dim st As New Date(1970,1,1,0,0,0)

            Sel ect Case xo("MsgType")

                Case "text","image","voice","video","shortvideo"

                    \'保存和收到的消息

                   Dim dr As DataRow = DataTables("Message").AddNew()

                    dr("FromUserName") = xo("FromUserName")

                    dr("CreateTime") = st.AddSeconds(xo("CreateTime"))

                    dr("MsgType") = xo("MsgType")

                    dr("MsgId") = xo("MsgId")

                    dr("MediaId") = xo("MediaId")

                    dr("ThumbMediaId") = xo("ThumbMediaId")

                    dr("PicUrl") = xo("PicUrl")

                    dr("Content") = xo("Content")

                    dr("Format") = xo("Format")

                    dr("Recognition") = xo("Recognition")

                    dr.Save()

                       MessageBox.Show("消息保存成功")

 

                    \'Functions.Execute("SaveMessage",e)

          end sel ect

End sel ect


--  作者:有点甜
--  发布时间:2017/9/10 11:00:00
--  
httprequest事件和VerifySignature函数,分别加入msgbox,看弹出什么。
--  作者:sjx71
--  发布时间:2017/9/10 14:47:00
--  
我在httprequest事件中写了msgbox,只显示 hpptmothod=Get 后的
 httpmothod = post 后的不显示

在VerifySignature函数中加的也可以显示

另外,JS接口安全域名内应该填写什么内容,我没有填写,出现问题是不是与这个参数有关

--  作者:有点甜
--  发布时间:2017/9/10 15:26:00
--  

配置成功了没有?贴出你写的 VerifySignature 事件代码。贴出你接口配置的信息。

 

http://www.foxtable.com/mobilehelp/scr/0175.htm

 


--  作者:sjx71
--  发布时间:2017/9/10 15:42:00
--  
Dim e As RequestEventArgs = Args(0)
Dim token = "foxtable" \'必须和设置的Token相同
Dim signature As String = e.GetValues("signature")
Dim timestamp As String = e.GetValues("timestamp")
Dim nonce As String = e.GetValues("nonce")
Dim echostr As String = e.GetValues("echostr")
Dim aryTmp() As String = {token,timestamp,nonce}
Array.Sort(aryTmp)
Dim strTmp As String = String.Join("", aryTmp)
strTmp = Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strTmp, "SHA1")
Return signature = strTmp.ToLower


111.204.*.*   为公网IP
  

url  http://111.204.*.*/wefox/
token  foxtable

[此贴子已经被作者于2017/9/10 15:43:12编辑过]

--  作者:有点甜
--  发布时间:2017/9/10 16:14:00
--  

我根据例子,用 ngrok 测试没问题。

 

https://www.ngrok.cc/

 

http://www.sunnyos.com/article-show-67.html

 

验证的时候,必须及时响应,如果回应太慢,就会配置失败的。你尝试在httprequest单独只写下面代码(其余全部删除)

 

Select Case e.path
    Case "wefox"
        If e.Request.HttpMethod.ToUpper = "GET"
            e.WriteString(e.GetValues("echostr"))
        End If
End Select


--  作者:sjx71
--  发布时间:2017/9/10 16:30:00
--  
还是显示配置失败
--  作者:有点甜
--  发布时间:2017/9/10 17:06:00
--  

 单独做一个项目,认认真真根据foxtable的例子操作。

 

 我测试代码没问题i,肯定是你哪一步弄错了。


--  作者:sjx71
--  发布时间:2017/9/10 17:15:00
--  
好的

谢谢甜老师