/** * 发送手机短消息 * * @param uri * @param m * @return */ public SipcRequest createSendSMSRequest(String uri, Message m) { SipcRequest req = this.createDefaultSipcRequest(SipcMethod.MESSAGE); req.addHeader(SipcHeader.TO, uri); req.addHeader(SipcHeader.EVENT, "SendCatSMS"); req.setBody(new SipcBody(m.getText())); return req; }
/** 创建定时短信 */ public SipcRequest createCreateScheduleSMSRequest( Date sendDate, Message message, Collection<Buddy> receiverList) { SipcRequest req = this.createDefaultSipcRequest(SipcMethod.SERVICE); req.addHeader(SipcHeader.EVENT, "SSSetScheduleCatSms"); String body = MessageTemplate.TMPL_CREATE_SCHEDULE_SMS; SimpleDateFormat df = new SimpleDateFormat("yyyy-M-d H:m:s"); df.setTimeZone(TimeZone.getTimeZone("GMT 0")); body = body.replace("{sendDate}", df.format(sendDate)); body = body.replace("{message}", message.getText()); String receiverTmpl = "<receiver uri=\"{uri}\" />"; StringBuffer buffer = new StringBuffer(); Iterator<Buddy> it = receiverList.iterator(); while (it.hasNext()) { Buddy b = it.next(); buffer.append(receiverTmpl.replace("{uri}", b.getUri())); } body = body.replace("{receiverList}", buffer.toString()); req.setBody(new SipcBody(body)); return req; }