以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  建议狐狸爸爸做个短信验证的完整例子(手机版,PC版)  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=144468)

--  作者:刘林
--  发布时间:2019/12/21 9:03:00
--  建议狐狸爸爸做个短信验证的完整例子(手机版,PC版)
老师:一直想找一个短信验证的例子,看了几个有关吉信通做的例子,比较散,对我们新手很难看懂,请问老师,能不能帮做个完整的例子挂出来供大家学习使用,步骤从如何申请,html代码,对我们新手来说好学点,这个内容相对来说大家比较通用。
[此贴子已经被作者于2019/12/21 9:04:20编辑过]

--  作者:有点蓝
--  发布时间:2019/12/21 9:17:00
--  
参考:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=122789&skin=0
--  作者:刘林
--  发布时间:2019/12/21 11:25:00
--  
Dim fl As String = ProjectPath & "web\\" & e.path
If filesys.FileExists(fl)
    Dim idx As Integer = fl.LastIndexOf(".")
    Dim ext As String = fl.SubString(idx)
    Select Case ext
        Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar"
            e.WriteFile(fl)
            Return \'这里必须返回
    End Select
End If

Select Case e.Path
    Case "test.htm"
        Dim wb As New weui
        wb.AddForm("","form1","valid.htm").Attribute=""
        With wb.AddInputGroup("form1","ipg1","线上预约")
            With .AddInputCell("ic4") \'通过InputCell增加输入框
                .AddLabel("lsj","手机",0) \'增加标签,0显示在左边
                .AddInput("sjh","text",1) \'增加输入框,1表示显示在中间
                .AddVcodeButton("vyz","获取验证码",2).Attribute=""
            End With
            With .AddInputCell("ic5") \'通过InputCell增加输入框
                .AddLabel("lyzm","验证码",0) \'增加标签,0显示在左边
                .AddInput("yzm","text",1) \'增加输入框,1表示显示在中间
            End With
            With wb.AddButtonGroup("form1","btg1",True)
                .Add("btn1", "确定", "submit")
            End With
        End With
        wb.AppendHTML("<script src=\'./lib/test.js\'></script>") \'引入脚本文件
        e.WriteString(wb.Build) \'生成网页
    Case "faduanxin.htm"
        Dim yzm As String = Rand.Next(10000, 99999)
        Dim shoujihao As String = e.PlainText
        Dim url As String
        url = "http://fesms.market.alicloudapi.com/sms/?id=wuzhan588&pwd=wuzhan588&to=" & shoujihao & "&c&time=" 
        Dim hc As New HttpClient(url)
        Dim result As String = "000" \'hc.GetData()
        If result.split("/")(0) = "000" Then
            e.AppendCookie(shoujihao, yzm)
            e.WriteString(yzm & ",测试!发送完毕!如果60秒后没有收到短信请重新发送!")
        Else
            e.WriteString("发送失败,稍后重试")
        End If
    Case "valid.htm"
        Dim sjh As String = e.Values("sjh")

        Dim yzm As String = e.Values("yzm")
        If e.Cookies.ContainsKey(sjh) = False Then
            e.WriteString("请点击发送验证码")
            Return
        End If
        If e.Cookies(sjh) <> yzm Then
            e.WriteString("验证码不正确")
            Return
        End If
        e.WriteString("ok")
End Select




[此贴子已经被作者于2019/12/21 11:27:17编辑过]

--  作者:有点蓝
--  发布时间:2019/12/21 11:33:00
--  
短信开发文档的地址发过来看看
[此贴子已经被作者于2019/12/21 11:33:11编辑过]

--  作者:刘林
--  发布时间:2019/12/21 11:35:00
--  
https://market.aliyun.com/products/57126001/cmapi024822.html?spm=5176.2020520132.101.3.7b1d7218e3C4Wt#sku=yuncode1882200000
--  作者:有点蓝
--  发布时间:2019/12/21 11:55:00
--  
代码命令窗口测试通了再用,code、phone各种参数改为自己的值(红色部分内容)

Dim hc As New HttpClient("https://fesms.market.alicloudapi.com/sms/?code=12345678&phone=13547119500&skin=1&sign=175622")
hc.Headers.Add("Authorization","APPCODE" & " " & "APPCODE值如7858a126750949e4a36371580f420413")
Dim ret As String = hc.GetData
msgbox(ret)

--  作者:刘林
--  发布时间:2019/12/21 13:46:00
--  
Dim fl As String = ProjectPath & "web\\" & e.path
If filesys.FileExists(fl)
    Dim idx As Integer = fl.LastIndexOf(".")
    Dim ext As String = fl.SubString(idx)
    Select Case ext
        Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar"
            e.WriteFile(fl)
            Return \'这里必须返回
    End Select
End If

Select Case e.Path
    Case "test.htm"
        Dim wb As New weui
        wb.AddForm("","form1","valid.htm").Attribute=""
        With wb.AddInputGroup("form1","ipg1","线上预约")
            With .AddInputCell("ic4") \'通过InputCell增加输入框
                .AddLabel("lsj","手机",0) \'增加标签,0显示在左边
                .AddInput("sjh","text",1) \'增加输入框,1表示显示在中间
                .AddVcodeButton("vyz","获取验证码",2).Attribute=""
            End With
            With .AddInputCell("ic5") \'通过InputCell增加输入框
                .AddLabel("lyzm","验证码",0) \'增加标签,0显示在左边
                .AddInput("yzm","text",1) \'增加输入框,1表示显示在中间
            End With
            With wb.AddButtonGroup("form1","btg1",True)
                .Add("btn1", "确定", "submit")
            End With
        End With
        wb.AppendHTML("<script src=\'./lib/test.js\'></script>") \'引入脚本文件
        e.WriteString(wb.Build) \'生成网页
    Case "faduanxin.htm"
        Dim yzm As String = Rand.Next(10000, 99999)
        Dim shoujihao As String = e.PlainText
        Dim url As String        
        Dim hc As New HttpClient("https://fesms.market.alicloudapi.com/sms/?code=" & yzm & "&ph&skin=1&sign=175622")
        hc.Headers.Add("Authorization","APPCODE" & " " & "fceec16c89094b5b9e5d0bf6639b9d48")
        Dim result As String = "000" \'hc.GetData()
        If result.split("/")(0) = "000" Then
            e.AppendCookie(shoujihao, yzm)
            e.WriteString(yzm & ",测试!发送完毕!如果60秒后没有收到短信请重新发送!")
        Else
            e.WriteString("发送失败,稍后重试")
        End If
    Case "valid.htm"
        Dim sjh As String = e.Values("sjh")

        Dim yzm As String = e.Values("yzm")
        If e.Cookies.ContainsKey(sjh) = False Then
            e.WriteString("请点击发送验证码")
            Return
        End If
        If e.Cookies(sjh) <> yzm Then
            e.WriteString("验证码不正确")
            Return
        End If
        e.WriteString("ok")
End Select


窗口测试通过了的,改成上面的代码不没反应呢,请问怎么改?



--  作者:有点蓝
--  发布时间:2019/12/21 14:02:00
--  
        Dim hc As New HttpClient("https://fesms.market.alicloudapi.com/sms/?code=" & yzm & "&ph&skin=1&sign=175622")
        hc.Headers.Add("Authorization","APPCODE" & " " & "fceec16c89094b5b9e5d0bf6639b9d48")
        Dim result As String = hc.GetData()
Dim jo As JObject = Jobject.Parse(result)
        If jo("code")="OK" Then
            e.AppendCookie(shoujihao, yzm)
            e.WriteString(yzm & ",测试!发送完毕!如果60秒后没有收到短信请重新发送!")
        Else
            e.WriteString(jo("Message"))
        End If

--  作者:刘林
--  发布时间:2019/12/25 21:41:00
--  
Dim ret As String = hc.GetData
msgbox(ret)


返回的是一个总的情况

请问老师,如何分别判断每种情况,如发送成功,做个对话框,电话号码错误做个对话框

yzm = Rand.Next(1000, 9999)
Dim phone As String = StrToNarrow(e.Form.Controls("sjhm").text)
Dim url As String
Dim hc As New HttpClient("https://fesms.market.alicloudapi.com/sms/?code=" & yzm & "&ph&skin=1&sign=175622")
hc.Headers.Add("Authorization","APPCODE" & " " & "93e06aa96db14005917768767c907445")
\'messagebox.show("验证码短信已发送至手机,请及时输入验证码并确认验证")
Dim ret As String = hc.GetData
msgbox(ret)


还有个问题如果用蓝色的这句代码就手机就收不到短信,但用红色这句就可以收到,是什么原因
短信收到内容为:[涪擎科技]你好,您的验证码是:7493,二十分中内有效,如何把涪擎科技换成我的项目名称


[此贴子已经被作者于2019/12/25 21:47:26编辑过]

--  作者:有点蓝
--  发布时间:2019/12/26 9:22:00
--  
就是8楼的用法呀

If jo("code")="OK" Then
            e.AppendCookie(shoujihao, yzm)
            e.WriteString(yzm & ",测试!发送完毕!如果60秒后没有收到短信请重新发送!")
        Else
这里改为提示,如:
http://www.foxtable.com/mobilehelp/topics/0058.htm
http://www.foxtable.com/mobilehelp/topics/0080.htm
http://www.foxtable.com/mobilehelp/topics/0082.htm
            ‘’e.WriteString(jo("Message"))
        End If

调用【hc.GetData】才会真正调用接口,弹个提示和接口调用没有半毛钱的关系