package com.panzhihua.common.utlis; import org.json.JSONObject; import org.json.XML; public class SmsUtil { private final static String URL = "https://106.ihuyi.com/webservice/sms.php?method=Submit"; private final static String ACCOUNT="C87595580"; private final static String PASSWORD="b66d918a598ad126b85b13e82a38e165"; private final static String CONTENT="您有一笔订单还未付款,超时未付款订单将自动取消。"; public static int sendCode(String mobile, String code){ try { String requestUrl=URL+"&account="+ACCOUNT+"&password="+PayUtil.MD5(PASSWORD)+"&mobile="+mobile+"&content="+"您的验证码是:"+code+"。请不要把验证码泄露给其他人。"; String res=HttpClientUtil.httpGet(requestUrl, null,null); JSONObject jsonObject=XML.toJSONObject(res); if(jsonObject.get("SubmitResult")!=null){ JSONObject result= (JSONObject) jsonObject.get("SubmitResult"); if(result.get("code").equals(2)){ return 1; } } } catch (Exception e) { e.printStackTrace(); } return 0; } public int sendContent(String mobile){ try { String requestUrl=URL+"&account="+ACCOUNT+"&password="+PayUtil.MD5(PASSWORD)+"&mobile="+mobile+"&content="+CONTENT; String res=HttpClientUtil.httpGet(requestUrl, null,null); JSONObject jsonObject=XML.toJSONObject(res); if(jsonObject.get("SubmitResult")!=null){ JSONObject result= (JSONObject) jsonObject.get("SubmitResult"); if(result.get("code").equals(2)){ return 1; } } } catch (Exception e) { e.printStackTrace(); } return 0; } }