短信验证码接口是网站、APP等应用的短信API接口。具有网站应用、APP注册、远程登录、订单支付等功能。由于短信验证码接口传输速度快、运行稳定、安全性高、到达率高,迅速成为企业网站和APP必不可少的认证功能。以网站和APP的注册操作为例,通过短信验证码接口的连接,实现了用户身份真实性的验证,避免了大量无效注册和无用数据的产生。
在界面测试中,对于登录功能,为了网站的安全性,大多数网站都会使用验证码功能。测试时,如何读取验证码的值也是很重要的一点。本文希望能为大家提供一些思路和方法。一、验证码类型验证码可分为:短信验证码、图文验证码、语音验证码、回答验证码。
1、短信验证码:输入手机号获取验证码。通常,验证码是一个数字。
2、图形验证码:网页中用于注册、登录等的验证码一般是服务器后端生成的验证码,然后绘制验证码生成图
3、语音验证码:服务器使用语音技术生成的验证码。
4、答案验证码:对于12306等网站,从题库中随机抽取题目,保存答案。
下面是C语言短信接口代码,仅供参考,适用于闪速码(www.shansuma.com)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Sms sms = new Sms();
string mobile = textBox3.Text.ToString();
string timestamp = sms.Timestamp();
string app_id = textBox1.Text.ToString();
string secretKey = textBox2.Text.ToString();
string method = "sms.message.send";
string version = "1.0";
string sign_type = "md5";
string smssign = sms.String2Unicode(textBox4.Text.ToString());
//type 验证码类型为0
string biz_content = "{\"mobile\":[\"" + mobile + "\"],\"sign\":\"" + smssign + "\",\"send_time\":\"\",\"type\":0,\"template_id\":\"" + textBox5.Text.ToString() + "\",\"params\":{\"code\":" + textBox6.Text.ToString() + "}}";
string sign = sms.getSmssign(app_id, biz_content, method, sign_type, timestamp, version, secretKey);
string res = sms.sendsms("http://api.shansuma.com/gateway.do", timestamp, HttpUtility.UrlEncode(app_id), method, version, sign_type, sign, HttpUtility.UrlEncode(biz_content));
MessageBox.Show(res);
}
}
}