**1、**发送验证码
server-name/sys/sendPhoneSms
POST
请求参数 | 参数类型 | 参数说明 |
---|
gid | String | 游戏编号 |
ph | String | 手机号码 |
{
"gid":"",
"ph":"13900000000"
}
返回参数 | 参数类型 | 参数说明 |
---|
success | boolean | 业务处理状态:false=失败;true=成功 |
code | String | 业务响应code |
msg | String | 业务响应code对应中文信息 |
data | String | 响应数据 |
{
"success":true,
"code":200,
"msg":"操作成功",
"data":""
}
序号 | 状态码 | 说明 |
---|
1 | 1000 | 手机号码不合法 |
2 | 1001 | 游戏不存在 |
3 | 1002 | 发送验证码失败,稍后重试 |
#region 发送post请求
public static string Post(string str)
{
string result = “”;
str = “gid=2a534077623b96e9edb93abb26ce286a&&ph=15179100145”;
Debug.LogError(str);
System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(“http://115.159.104.25:9999/sys/sendPhoneSms”);
req.Method = “POST”;
req.ContentType = “application/x-www-form-urlencoded”;
byte[] data = System.Text.Encoding.UTF8.GetBytes(str);//把字符串转换为字节
req.ContentLength = data.Length; //请求长度
using (System.IO.Stream reqStream = req.GetRequestStream()) //获取
{
reqStream.Write(data, 0, data.Length);//向当前流中写入字节
reqStream.Close(); //关闭当前流
}
System.Net.HttpWebResponse resp = (System.Net.HttpWebResponse)req.GetResponse(); //响应结果
System.IO.Stream stream = resp.GetResponseStream();
//获取响应内容
using (System.IO.StreamReader reader = new System.IO.StreamReader(stream, System.Text.Encoding.UTF8))
{
result = reader.ReadToEnd();
}
Debug.LogError(result);
return result;
}
#endregion