Foxtable(狐表)用户栏目专家坐堂 → 建议狐狸爸爸做个短信验证的完整例子(手机版,PC版)


  共有3838人关注过本帖树形打印复制链接

主题:建议狐狸爸爸做个短信验证的完整例子(手机版,PC版)

帅哥哟,离线,有人找我吗?
刘林
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
建议狐狸爸爸做个短信验证的完整例子(手机版,PC版)  发帖心情 Post By:2019/12/21 9:03:00 [显示全部帖子]

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

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By: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编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2019/12/21 11:35:00 [显示全部帖子]

https://market.aliyun.com/products/57126001/cmapi024822.html?spm=5176.2020520132.101.3.7b1d7218e3C4Wt#sku=yuncode1882200000

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By: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


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



 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By: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编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2019/12/26 20:24:00 [显示全部帖子]


Dim result As String = hc.GetData()
Dim jo As JObject = Jobject.Parse(result)
If jo("code")="OK" Then
    messagebox.show("验证码短信已发送至手机,请及时输入验证码并确认验证")
Else
    messagebox.show(jo("Message"))
End If

请问发送成功了显示的对话是OK,而不是"验证码短信已发送至手机,请及时输入验证码并确认验证"

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2019/12/28 11:38:00 [显示全部帖子]

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" & " " & "5b33f5a0475d45df9ba68479b11085f3")
Dim result As String = hc.GetData()
Dim jo As JObject = Jobject.Parse(result)
If jo("Message")="OK" Then
    e.Sender.Enabled=False
e.Form.TimerEnabled = True
    messagebox.show("验证码短信已发送至手机,请及时输入验证码并确认验证")
Else
    messagebox.show(jo("Message"))
End If

请问老师,在有的电脑上不管什么电话号码都出现,手机收不到短信
 The remote name could not be resolved: 'fesms.market.alicloudapi.com'

但在有的电脑上电话号码都可以,怎么办?



 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2019/12/28 12:12:00 [显示全部帖子]

老师,这是同一项目程序,同一电话号在有的电脑上出现的问题哒,如果说是对方服务的问题,为什么在有的电脑上不出这问题

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2019/12/28 13:30:00 [显示全部帖子]

我问了服务商回答 尊敬的客户,您好,是域名无法解析,另外你是否设置了默认代理?跟您电脑上网的代理有关。

我在网上找了处理办法cmd >ipconfig/flushdns
测试没有上面问题了,但又出现这个错是什么意思,怎么办?

 The underlying connection was closed: An unexpected error occurred on a send.
Received an unexpected EOF or 0 bytes from the transport stream.
Error reading JObject from JsonReader. Path '', line 0, position 0.



 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2020/1/10 20:50:00 [显示全部帖子]


老师,短信验证API做起了,再请教一个手写识别这个API代码什么写,谢谢
https://market.aliyun.com/products/57124001/cmapi011524.html?spm=5176.2020520132.101.2.715b7218OVNm1x#sku=yuncode552400008

 回到顶部
总数 18 1 2 下一页