这个自己写吗? 我建议直接调用短信平台的接口不就行了吗?
//接口地址
//分发时间
Map param=new HashMap (;
param.put('name ','用户帐户');
param.put(pwd )、Tools.MD5 )、用户密码(mdzmttime );
param.put('content ',URLEncoder.encode ) )【阅读信件确认邮件验证码】验证码888888,死了也不能告诉别人哦。 ',' UTF-8 ' );
param.put(phone,) 13400000000 );
param.put('subid ','');
param.put('mttime ',mttime );
HTPtool.sendpost(URL,param );
开机自检提交方法
publicstaticstringsendpost (string URL,映射参数)。
log.I('post提交: [ URL=' mdzurlmdz ' ] ' mdzparams.tostring ) );
//构建请求参数
if (参数!=null ) {
(实体: params.entryset () ) ) ) ) )。
sb.append(e.getkey ) ).append ('='.append ).getvalue ) ) ).append ) );
}
sb.substring(0,sb.length ) (- 1 );
}
//尝试发送请求
try {
u=newURL(URL;
con=(httpurlconnection ) u.openConnection );
con.setrequestmethod(post );
con.setconnecttimeout(6000;
con.setdooutput(true;
con.setdoinput(true;
con.setusecaches(false;
con.setrequestproperty (content-type,) application/x-www-form-urlencoded );
outputstreamwriterosw=newoutputstreamwriter (con.get output stream ),' UTF-8 ' );
OSW.write(sb.tostring ) );
osw.flush (;
osw.close (;
}catch(exceptione ) {
log.e(e );
} finally {
if (康!=null ) {
con.disconnect (;
}
}
//读取返回内容
try {
while((temp=br.readline ) )!=null ) {
buffer.append(temp ).append ) ' n );
}
}catch(exceptione ) {
log.e(e );
}
log.I(post响应) mdzbuffer.toString );
return buffer.toString (;
}
publicstaticstringmd5(stringstr ) {
消息诊断MD5=null;
try{
MD5=消息digest.getinstance (MD5 );
}catch(exceptione ) {
log.I(e.getmessage ) );
返回' ';
}
char [ ] char array=str.tochararray (;
byte [ ] bytearray=new byte [ char array.length ];
for(intI=0; i charArray.length; imdzmdz )
byteArray[i]=(byte ) charArray[i];
byte [ ] m D5 bytes=MD5.digest (bytearray );
for(intI=0; i md5Bytes.length; imdzmdz ) {
intval=(int ) md5Bytes[i] )0xff;
if(val16 ) {
hexvalue.append('0);
}
hex value.append (integer.to hex string (val ) );
}
return hexValue.toString (;
}