|  |  |  | 
|---|
|  |  |  | return 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public   boolean sendSingleSms(String mobile,String content) throws SDKParamsException { | 
|---|
|  |  |  | public   boolean sendSingleSms(String mobile,String content)  { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | client = new SmsSDKClient(ip,port,appKey,appSecret); | 
|---|
|  |  |  | } catch (SDKParamsException e) { | 
|---|
|  |  |  | throw new RuntimeException(e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(client == null){ | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String customSmsId = "1"; | 
|---|
|  |  |  | String extendedCode = "01"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SmsSingleRequest request = new SmsSingleRequest(mobile, content, customSmsId, extendedCode, ""); | 
|---|
|  |  |  | ResultModel<SmsResponse> result = client.sendSingleSms(request); | 
|---|
|  |  |  | saveInterfaceLog(ip+"/"+port,"【短信】发送", JSONObject.toJSONString(result),JSONObject.toJSONString(result)); | 
|---|
|  |  |  | if (result.getCode().equals("SUCCESS")) { | 
|---|
|  |  |  | System.out.println("请求成功"); | 
|---|
|  |  |  | SmsResponse response = result.getResult(); | 
|---|
|  |  |  | System.out.println("sendSingleSms:" + response.toString()); | 
|---|
|  |  |  | return  true; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | System.out.println("请求失败"); | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | if(client == null){ | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String customSmsId = "1"; | 
|---|
|  |  |  | String extendedCode = "01"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SmsSingleRequest request = new SmsSingleRequest(mobile, content, customSmsId, extendedCode, ""); | 
|---|
|  |  |  | ResultModel<SmsResponse> result = client.sendSingleSms(request); | 
|---|
|  |  |  | saveInterfaceLog(ip+"/"+port,"【短信】发送", JSONObject.toJSONString(result),JSONObject.toJSONString(result)); | 
|---|
|  |  |  | if (result.getCode().equals("SUCCESS")) { | 
|---|
|  |  |  | System.out.println("请求成功"); | 
|---|
|  |  |  | SmsResponse response = result.getResult(); | 
|---|
|  |  |  | System.out.println("sendSingleSms:" + response.toString()); | 
|---|
|  |  |  | return  true; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | System.out.println("请求失败"); | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|