以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 还是不明白短信验证码的代码 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=104399) |
-- 作者:i4whylg -- 发布时间:2017/7/28 15:19:00 -- 还是不明白短信验证码的代码 买了吉信通的接口,如下图,获取验证码的按钮的代码怎么写? C#文档: public static string PostData(string purl,string str) { try { byte[] data = System.Text.Encoding.GetEncoding("GB2312").GetBytes(str); // 准备请求 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(purl); //设置超时 req.Timeout = 30000; req.Method = "Post"; req.C; req.ContentLength = data.Length; Stream stream = req.GetRequestStream(); // 发送数据 stream.Write(data, 0, data.Length); stream.Close(); HttpWebResponse rep = (HttpWebResponse)req.GetResponse(); Stream receiveStream = rep.GetResponseStream(); Encoding encode = System.Text.Encoding.GetEncoding("GB2312"); // Pipes the stream to a higher level stream reader with the required encoding format. StreamReader readStream = new StreamReader(receiveStream, encode); Char[] read = new Char[256]; int count = readStream.Read(read, 0, 256); StringBuilder sb = new StringBuilder(""); while (count > 0) { String readstr = new String(read, 0, count); sb.Append(readstr); count = readStream.Read(read, 0, 256); } rep.Close(); readStream.Close(); return sb.ToString(); } catch (Exception ex) { return "posterror"; // ForumExceptions.Log(ex); } } 调用方法 string backinfo=PostData("http://service.winic.org:8009/sys_port/gateway/index.asp?", "id=" + uid + "&pwd=" + pwd + "&to=" + to + "&c&time="); string uid = "帐号"; string pwd = "密码"; string to = "手机号"; string c; |
-- 作者:有点甜 -- 发布时间:2017/7/28 17:57:00 -- 1、你发送短信成功了吗?能否发送成功?
http://www.foxtable.com/webhelp/scr/2243.htm
2、如果能发,按钮直接写代码
sendAjaxText(document.getElementById("sjh").value, "faduanxin.htm","",false);
你在httprequest事件,处理 faduanxin.htm 发送信息即可。 |
-- 作者:i4whylg -- 发布时间:2017/7/30 14:24:00 -- 甜版主,短信在foxtable的桌面端里会写了,能发送,就是faduanxin.htm这个不会写啊,页面都设计好了,就卡在这里了,现在还只会照着教程,不会融会贯通。能否有空指点一下? [此贴子已经被作者于2017/7/30 14:31:36编辑过]
|
-- 作者:i4whylg -- 发布时间:2017/7/30 14:35:00 -- 这是有点蓝版主回答zhangjian222200帖子的,就是吉信通的应该怎么改 Dim e As RequestEventArgs = args(0) \'注册第1页,注册 e.Resp Select Case e.path Case "fasongduanxin.htm" Dim shoujihao As String = e.PlainText \'赋值手机号,执行职能得到结果:isj \'使用e.PostValues("isj") ,提示:参数 mobile 格式不正确,mobile不能为空 Dim hc As New HttpClient("https://sms.yunpian.com/v2/sms/single_send.json") Dim Val As Integer = Rand.Next(2001,9999) \'生成200到300之间的随机整数 Dim text = "【郎窝网】您的验证码是" & Val & ".如非本人操作,请忽略本短信" hc.C hc.C & shoujihao & "&text=" & UrlEncode(text) output.show(hc.getData()) e.WriteString("发送完毕!如果60秒后没有收到短信请重新发送!") End Select |
-- 作者:有点甜 -- 发布时间:2017/7/30 15:08:00 -- 这样写
Case "faduanxin.htm" Dim shoujihao As String = e.PlainText
\'这里写你发短信的代码,参考2楼,手机号,改成变量shoujihao
e.WriteString("发送完毕!如果60秒后没有收到短信请重新发送!")
|
-- 作者:i4whylg -- 发布时间:2017/7/31 1:54:00 -- 版主能不能直接给出用吉信通发验证短信的这段代码,看到半夜还是不行啊 |
-- 作者:有点甜 -- 发布时间:2017/7/31 8:56:00 -- Case "faduanxin.htm" Dim shoujihao As String = e.PlainText Dim url = "http://service.winic.org:8009/sys_port/gateway/?id=您的账号&pwd=您的密码&to=" & shoujihao & "&content=短信内容&time=" Dim hc As New HttpClient(url) Dim result As String = hc.GetData() MessageBox.Show(result) e.WriteString("发送完毕!如果60秒后没有收到短信请重新发送!") |
-- 作者:i4whylg -- 发布时间:2017/8/1 18:51:00 -- [此贴子已经被作者于2017/8/1 18:57:25编辑过]
|
-- 作者:i4whylg -- 发布时间:2017/8/1 18:58:00 -- 麻烦版主看看,还是没成功。 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) 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","test.htm") With wb.AddInputGroup("form1","ipg1","基本资料") With .AddInputCell("ic1") \'通过InputCell增加输入框(1表示突出显示,2表示红色警示图标) .AddLabel("lsj","手机",0) \'增加标签(0显示在左边) .AddInput("isj","text",1).PlaceHolder= "请输入手机号" \'增加输入框(0靠左显示,1居中显示,2靠右显示) End With With .AddInputCell("ic2") .AddLabel("lyz","验证",0) .AddInput("iyz","text",1).PlaceHolder= "请输入验证码" .AddVcodeButton("vyz","获取验证码",2).Attri-bute="on-click=\'getNum()\'" End With End With wb.AppendHTML("<script src=\'./lib/ajaxform.js\'></script>") \'引入脚本文件 e.WriteString(wb.Build) \'生成网页 Case "faduanxin.htm" Dim shoujihao As String = e.PlainText Dim url = "http://service.winic.org:8009/sys_port/gateway/?id=zhanghao&pwd=mima&to=" & shoujihao & "&content=验证码是12345&time=" Dim hc As New HttpClient(url) Dim result As String = hc.GetData() e.WriteString("发送完毕!如果60秒后没有收到短信请重新发送!") End Select ************************ js代码为: function getNum(){ alert("ok"); \'这个被执行了 var result = sendAjaxText(document.getElementById("isj").value, "faduanxin.htm","",false); ‘这个没被执行 alert(result); ‘这个没被执行’ } [此贴子已经被作者于2017/8/1 19:03:01编辑过]
|
-- 作者:有点蓝 -- 发布时间:2017/8/1 20:11:00 -- Case "faduanxin.htm" Dim shoujihao As String = e.PlainText msgbox(shoujihao ) ‘这里能不能弹出手机号’ Dim url = "http://service.winic.org:8009/sys_port/gateway/?id=zhanghao&pwd=mima&to=" & shoujihao & "&content=验证码是12345&time=" Dim hc As New HttpClient(url) Dim result As String = hc.GetData() msgbox(result ) ‘这里又弹出什么内容’ e.WriteString("发送完毕!如果60秒后没有收到短信请重新发送!") |