httpUrlConnection 实现向手机号发送验证码
来源:互联网 发布:分治算法 编辑:程序博客网 时间:2024/04/29 21:26
public static boolean isNetWorkConn(Context context) {
boolean flags = false;
ConnectivityManager manager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getActiveNetworkInfo();
if (info != null) {
return info.isConnected();
}
return flags;
}
public static boolean isMobileNO(String mobiles) {
// Pattern p =
// Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
Pattern p = Pattern
.compile("^((13[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$");
Matcher m = p.matcher(mobiles);
return m.matches();
}
public static String sendCheckCode(Context mcContext, String url,
String telphoneNumber, String check_Code) {
String result = "";
URL url2;
InputStream is;
InputStreamReader isr;
BufferedReader br;
try {
url2 = new URL(url);
HttpURLConnection connection = (HttpURLConnection) url2
.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
connection.connect();
OutputStream os = connection.getOutputStream();
// os.write("account=cf_hbws&password=Icebox_1&mobile=15010251210&content=您的验证码是:485613。请不要把验证码泄露给其他人。"
// .getBytes());
os.write(("account=cf_hbws&password=Icebox_1&mobile="
+ telphoneNumber + "&content="
+ mcContext.getString(R.string.your_checkCode) + check_Code + mcContext
.getString(R.string.no_Tell_others)).getBytes());
int code = connection.getResponseCode();
if (code == HttpURLConnection.HTTP_OK) {
is = connection.getInputStream();
isr = new InputStreamReader(is, "UTF-8");
String line = "";
br = new BufferedReader(isr);
while ((line = br.readLine()) != null) {
result += line;
}
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
boolean flags = false;
ConnectivityManager manager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getActiveNetworkInfo();
if (info != null) {
return info.isConnected();
}
return flags;
}
public static boolean isMobileNO(String mobiles) {
// Pattern p =
// Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
Pattern p = Pattern
.compile("^((13[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$");
Matcher m = p.matcher(mobiles);
return m.matches();
}
public static String sendCheckCode(Context mcContext, String url,
String telphoneNumber, String check_Code) {
String result = "";
URL url2;
InputStream is;
InputStreamReader isr;
BufferedReader br;
try {
url2 = new URL(url);
HttpURLConnection connection = (HttpURLConnection) url2
.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
connection.connect();
OutputStream os = connection.getOutputStream();
// os.write("account=cf_hbws&password=Icebox_1&mobile=15010251210&content=您的验证码是:485613。请不要把验证码泄露给其他人。"
// .getBytes());
os.write(("account=cf_hbws&password=Icebox_1&mobile="
+ telphoneNumber + "&content="
+ mcContext.getString(R.string.your_checkCode) + check_Code + mcContext
.getString(R.string.no_Tell_others)).getBytes());
int code = connection.getResponseCode();
if (code == HttpURLConnection.HTTP_OK) {
is = connection.getInputStream();
isr = new InputStreamReader(is, "UTF-8");
String line = "";
br = new BufferedReader(isr);
while ((line = br.readLine()) != null) {
result += line;
}
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
0 0
- httpUrlConnection 实现向手机号发送验证码
- java向手机号发送短信验证码
- 手机号发送验证码
- java实现更换手机号的功能(发送验证码)
- 给手机号发送验证码设置密码
- 发送手机验证码的js代码、手机号合法验证
- 简单实现手机号验证码注册功能
- 绑定手机号,并发送段信验证码
- Ajax前台发送短信验证码 (提取手机号,发送给php,php拿到手机号进行发送功能)
- pc端向手机发送验证码
- 用户注册填写手机号接收短信验证码怎么实现?
- 用短信验证码SDK实现手机号注册功能
- HttpUrlConnection消息发送失败重新发送实现
- 网站登录密码忘记后,通过向手机发送验证码实现找回密码的实现方法
- 短信验证(手机号注册,绑定手机号获取验证码)
- jquery 手机号验证码倒计时
- Android使用mob实现手机号验证注册
- ajax+php实现无刷新验证手机号
- 2071 Max Num
- Spring 事务
- Hibernate中的五种数据检索方式
- SpringMvc自动任务调度之task实现
- 欢迎使用CSDN-markdown编辑器
- httpUrlConnection 实现向手机号发送验证码
- VS2010编译mod_wsgi-py35-VC10.so(python35和Apache24)
- android -- 蓝牙 bluetooth (一) 入门
- c#调用C++ dll 的方法
- 《构建之法》读书笔记——第3章 软件工程师的成长
- golang编译程序从后台运行,不出现dos窗口
- Phaser.js 官方中文文档 phaser.io
- ConcurrentLinkedQueue学习(一)
- asp.net mvc(参考asp.net开发指南)