真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

發(fā)短信Java代碼 android發(fā)短信代碼

java發(fā)送手機(jī)短信

package?com.winhands.quartz;

創(chuàng)新互聯(lián)建站是少有的成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、營(yíng)銷型企業(yè)網(wǎng)站、微信小程序、手機(jī)APP,開發(fā)、制作、設(shè)計(jì)、賣友情鏈接、推廣優(yōu)化一站式服務(wù)網(wǎng)絡(luò)公司,成立與2013年,堅(jiān)持透明化,價(jià)格低,無(wú)套路經(jīng)營(yíng)理念。讓網(wǎng)頁(yè)驚喜每一位訪客多年來(lái)深受用戶好評(píng)

import?java.io.PrintWriter;

import?java.io.StringWriter;

import?java.io.UnsupportedEncodingException;

import?java.util.ArrayList;

import?java.util.Date;

import?java.util.HashMap;

import?java.util.List;

import?org.slf4j.Logger;

import?org.slf4j.LoggerFactory;

import?com.winhands.base.service.BaseService;

import?com.winhands.util.BaseConstant;

import?com.winhands.web.dict.entity.DictCommon;

import?com.winhands.web.xfhf.entity.SmsOutBox;

import?com.winhands.web.xfhf.entity.SmsVisit;

import?com.winhands.web.xfhf.entity.TaskInfo;

public?class?SmsSendSync?{

public?BaseService?baseService;

public?BaseService?baseServiceMas;

public?static?final?Logger?logger?=?LoggerFactory.getLogger(SmsSendSync.class);

//同步短信到mas機(jī)待發(fā)短信表

public?void?work()?{

//?任務(wù)ID?100001

//?首先查詢?nèi)蝿?wù)是否正在執(zhí)行

//?查詢列表

TaskInfo?taskInfo?=?new?TaskInfo();

taskInfo.setTask_id("100001");

try?{

taskInfo?=?(TaskInfo)?baseService.queryForObject("sms_send.queryTaskStatus",?taskInfo);

//如果狀態(tài)是處室狀態(tài)則執(zhí)行,否則此次任務(wù)不執(zhí)行

if?(BaseConstant.task_status_cs.equals(taskInfo.getTask_status()))?{

taskInfo.setTask_status(BaseConstant.task_status_zx);//設(shè)置任務(wù)執(zhí)行狀態(tài)為執(zhí)行

taskInfo.setTask_last_start_time(new?Date());//設(shè)置任務(wù)執(zhí)行開始時(shí)間

baseService.update("sms_send.updateTaskStatus",?taskInfo);//

//移動(dòng)號(hào)碼庫(kù)

HashMapString,String?hashMap?=?new?HashMapString,String();

//134?、135、136、137、138、139、150、151、152、158、159、182、183、184。157、187、188

hashMap.put("134",?"134");

hashMap.put("135",?"135");

hashMap.put("136",?"136");

hashMap.put("137",?"137");

hashMap.put("138",?"138");

hashMap.put("139",?"139");

hashMap.put("150",?"150");

hashMap.put("151",?"151");

hashMap.put("152",?"152");

hashMap.put("157",?"157");

hashMap.put("158",?"158");

hashMap.put("159",?"159");

hashMap.put("182",?"182");

hashMap.put("183",?"183");

hashMap.put("184",?"184");

hashMap.put("187",?"187");

hashMap.put("188",?"188");

SmsVisit?smsSend?=?new?SmsVisit();

smsSend.setSms_status(BaseConstant.sms_status_csh);

List?list?=?baseService.queryForList("sms_send.queryForSmsTask",?smsSend);

List?smsMasList?=?new?ArrayList();

List?smsList?=?new?ArrayList();

if?(list?==?null||list.size()==0)?return;//?如果列表為空,沒有待辦任務(wù),則任務(wù)結(jié)束

for?(int?i?=?0;?i??list.size();?i++)?{

smsSend?=?(SmsVisit)?list.get(i);

//String?msg?=?messagecontent(smsSend);

String?msg?=?smsSend.getSpare_2();

if(hashMap.get(smsSend.getVisit_phone().substring(0,?3))!=null){

SmsOutBox?smsOutBox?=?new?SmsOutBox();

smsOutBox.setSismsid(smsSend.getP_id());

smsOutBox.setReqdeliveryreport(BaseConstant.NoReport);

smsOutBox.setApplicationid(BaseConstant.APPLICATIONID);

smsOutBox.setDestaddr(smsSend.getVisit_phone());

smsOutBox.setMsgfmt(BaseConstant.MSGFMT);

smsOutBox.setRequesttime(new?Date());

smsOutBox.setExtcode(smsSend.getExtccode());

smsOutBox.setSendmethod(BaseConstant.NoMsg);//?正常短信

smsOutBox.setMessagecontent(msg);

smsMasList.add(smsOutBox);

}else{

boolean?con?=?true;

String?lastMsg?=?msg;

int?xh?=0;

while(con){

lastMsg?=?msg.substring(0,msg.length()??55???55?:?msg.length());

msg?=?msg.substring(msg.length()??55???55?:?msg.length(),msg.length());

if?(msg.equals(""))?{

con?=?false;

}

SmsOutBox?smsOutBox?=?new?SmsOutBox();

smsOutBox.setSismsid(smsSend.getP_id()+(xh==0?"":xh));

xh++;

smsOutBox.setReqdeliveryreport(BaseConstant.NoReport);

smsOutBox.setApplicationid(BaseConstant.APPLICATIONID);

smsOutBox.setDestaddr(smsSend.getVisit_phone());

smsOutBox.setMsgfmt(BaseConstant.MSGFMT);

smsOutBox.setRequesttime(new?Date());

smsOutBox.setExtcode(smsSend.getExtccode());

smsOutBox.setSendmethod(BaseConstant.NoMsg);//?正常短信

smsOutBox.setMessagecontent(lastMsg);

smsMasList.add(smsOutBox);

}

}

SmsVisit?smsSendTemp?=?new?SmsVisit();

smsSendTemp.setP_id(smsSend.getP_id());?

//smsSendTemp.setSpare_2(msg);//短信內(nèi)容

smsSendTemp.setSms_status_time(new?Date());

smsSendTemp.setSms_status(BaseConstant.sms_status_yfswg);?

smsList.add(smsSendTemp);

}

baseService.insertBatch("sms_send.insertSmsOutBox",?smsMasList);//插入本地歷史記錄表

baseServiceMas.insertBatch("sms_mas.insertSmsOutBox",?smsMasList);//插入mas機(jī)待發(fā)送表

baseService.updateBatch("sms_send.updateSmsVisit",?smsList);//更新回訪記錄狀態(tài)

}

}?catch?(Exception?e)?{

e.printStackTrace();

//baseService.saveLog("同步短信到mas機(jī)待發(fā)短信表",?"100001",?"同步短信到mas機(jī)待發(fā)短信表錯(cuò)誤");

logger.error("同步短信到mas機(jī)待發(fā)短信表錯(cuò)誤",?getTrace(e));

}finally{

try?{

taskInfo.setTask_status(BaseConstant.task_status_cs);//設(shè)置任務(wù)執(zhí)行狀態(tài)為初始

taskInfo.setTask_last_end_time(new?Date());//設(shè)置任務(wù)執(zhí)行結(jié)束時(shí)間

taskInfo.setTask_status_desc("任務(wù)執(zhí)行結(jié)束");

baseService.update("sms_send.updateTaskStatus",?taskInfo);//

}?catch?(Exception?e2)?{

e2.printStackTrace();

//?TODO:?handle?exception

}

}

}

public?String?messagecontent(SmsVisit?smsSend){

//XX,您好!您于XX月XX日辦理XX業(yè)務(wù)(或XX,您好!XX大隊(duì)于XX月XX日對(duì)你單位進(jìn)行監(jiān)督檢查/行政處罰/火災(zāi)調(diào)查),現(xiàn)進(jìn)行滿意度回訪,請(qǐng)回復(fù)數(shù)字:1為滿意;2為基本滿意;3為不滿意。感謝您對(duì)消防工作的支持!回復(fù)免費(fèi)。宿遷市公安消防支隊(duì)

//首先根據(jù)業(yè)務(wù)類型來(lái)判斷采用哪種模板?監(jiān)察

StringBuffer?msg?=?new?StringBuffer("");?

if(BaseConstant.jiancha.equals(smsSend.getVisit_deal_business_type())){

msg.append(smsSend.getVisit_name_cn())

???.append(",您好!")

???.append(smsSend.getVisit_deal_org_name())

???.append("于")

???.append(smsSend.getVisit_deal_time().substring(4,?6)).append("月")

???.append(smsSend.getVisit_deal_time().substring(6,?8)).append("日")

???.append("對(duì)你單位進(jìn)行").append(DictCommon.getEntryMap(BaseConstant.jiancha).get(smsSend.getVisit_deal_business()))

???.append(",現(xiàn)進(jìn)行滿意度回訪,請(qǐng)回復(fù)數(shù)字:1為滿意;2為基本滿意;3為不滿意。感謝您對(duì)消防工作的支持!");

}else?if(BaseConstant.yewu.equals(smsSend.getVisit_deal_business_type())){

msg.append(smsSend.getVisit_name_cn())

???.append(",您好!您于")

???.append(smsSend.getVisit_deal_time().substring(4,?6)).append("月")

???.append(smsSend.getVisit_deal_time().substring(6,?8)).append("日")

???.append("辦理").append(smsSend.getVisit_deal_business()).append("業(yè)務(wù),")

???.append("現(xiàn)進(jìn)行滿意度回訪,請(qǐng)回復(fù)數(shù)字:1為滿意;2為基本滿意;3為不滿意。感謝您對(duì)消防工作的支持!");

}

return?msg.toString();

}

public?BaseService?getBaseService()?{

return?baseService;

}

public?void?setBaseService(BaseService?baseService)?{

this.baseService?=?baseService;

}

public?BaseService?getBaseServiceMas()?{

return?baseServiceMas;

}

public?void?setBaseServiceMas(BaseService?baseServiceMas)?{

this.baseServiceMas?=?baseServiceMas;

}

public?static?void?main(String[]?args){

List?smsMasList?=?new?ArrayList();?

try?{

String?msg?=?"***,您好!*********于2015年5月2日對(duì)你單位進(jìn)行監(jiān)督檢查,現(xiàn)進(jìn)行滿意度回訪,請(qǐng)回復(fù)數(shù)字:1為滿意;2為基本滿意;3為不滿意。感謝您對(duì)消防工作的支持!";

SmsOutBox?smsOutBox?=?new?SmsOutBox();

smsOutBox.setSismsid("12344");

smsOutBox.setReqdeliveryreport(BaseConstant.NoReport);

smsOutBox.setApplicationid(BaseConstant.APPLICATIONID);

smsOutBox.setDestaddr("111");

smsOutBox.setMsgfmt(BaseConstant.MSGFMT);

smsOutBox.setRequesttime(new?Date());

smsOutBox.setExtcode("2222");

smsOutBox.setSendmethod(BaseConstant.NoMsg);//?正常短信

boolean?con?=?true;

String?lastMsg?=?msg;

while(con){

lastMsg?=?msg.substring(0,msg.length()??55???55?:?msg.length());

msg?=?msg.substring(msg.length()??55???55?:?msg.length(),msg.length());

if?(msg.equals(""))?{

con?=?false;

}

SmsOutBox?smOutBox_temp?=?new?SmsOutBox();?

smOutBox_temp?=?smsOutBox;

smOutBox_temp.setMessagecontent(lastMsg);

?

smsMasList.add(smOutBox_temp);

}

for(Object?o:smsMasList){

SmsOutBox?smsOutBox2?=?(SmsOutBox)o;

System.out.println(smsOutBox2.getMessagecontent());

}

}?catch?(Exception?e)?{

//?TODO?Auto-generated?catch?block

e.printStackTrace();

}

}

public?static?String?getTrace(Throwable?t)?{

StringWriter?stringWriter=?new?StringWriter();

PrintWriter?writer=?new?PrintWriter(stringWriter);

t.printStackTrace(writer);

StringBuffer?buffer=?stringWriter.getBuffer();

return?buffer.toString();

}

}

短信不是你想發(fā)??想發(fā)就能發(fā),是收費(fèi)的,我們公司是租用的移動(dòng)MAS平臺(tái)的短信發(fā)送接收平臺(tái),上面那是和一個(gè)和mas同步的一個(gè)小程序,租用別人的mas平臺(tái)是收費(fèi)的,平臺(tái)有很多自己選擇,有發(fā)送接口可以調(diào),發(fā)送內(nèi)容自己提供

java怎么實(shí)現(xiàn)群發(fā)短信的功能

JAVA實(shí)現(xiàn)短信群發(fā)的步驟:

1、使用第三方短信平臺(tái)服務(wù)商,接入短信服務(wù);

2、調(diào)用短信提交頁(yè)面發(fā)送請(qǐng)求;

3、服務(wù)器向第三方短信平臺(tái)提交發(fā)送請(qǐng)求;

4、短信平臺(tái)通過運(yùn)營(yíng)商將短信下發(fā)至用戶的手機(jī)上。

以下是秒賽短信平臺(tái)JAVA短信驗(yàn)證碼接口代碼示例

package test;

import java.io.IOException;

import java.io.UnsupportedEncodingException;

import java.net.URISyntaxException;

import java.net.URLEncoder;

import org.apache.commons.httpclient.HttpClient;

import org.apache.commons.httpclient.NameValuePair;

import org.apache.commons.httpclient.methods.PostMethod;

import org.apache.commons.lang3.StringUtils;

public class Apis {

// 短信發(fā)送接口的http地址,請(qǐng)咨詢客服

private static String url = “xxxxxxxxxxxxxxxxxxxxxxxxxxxx”;

// 編碼格式。發(fā)送編碼格式統(tǒng)一用UTF-8

private static String ENCODING = “UTF-8”;

public static void main(String[] args) throws IOException, URISyntaxException {

// 賬號(hào)

String account = “************************”;

// 密碼

String pswd = “************************”;

// 修改為您要發(fā)送的手機(jī)號(hào),多個(gè)用,分割

String mobile = “13*********”;

// 設(shè)置您要發(fā)送的內(nèi)容

String msg = “【秒賽科技】您的驗(yàn)證碼是:1234”;

// 發(fā)短信調(diào)用示例

System.out.println(Apis.send(account,pswd, mobile, msg));

}

/**

* 發(fā)送短信

*

* @param account

* ? ? ? ? ? ?account

* @param pswd

* ? ? ? ? ? ?pswd

* @param mobile

* ? ? ? ? ? ?手機(jī)號(hào)碼

* @param content

* ? ? ? ? ? ?短信發(fā)送內(nèi)容

*/

public static String send(String account,String pswd, String mobile, String msg) {

NameValuePair[] data = { new NameValuePair(“account”, account),

new NameValuePair(“pswd”, pswd),

new NameValuePair(“mobile”, mobile),

new NameValuePair(“msg”, msg),

new NameValuePair(“needstatus”, “true”),

new NameValuePair(“product”, “”) };

return doPost(url, data);

}

/**

* 基于HttpClient的post函數(shù)

* PH

* @param url

* ? ? ? ? ? ?提交的URL

*

* @param data

* ? ? ? ? ? ?提交NameValuePair參數(shù)

* @return 提交響應(yīng)

*/

private static String doPost(String url, NameValuePair[] data) {

HttpClient client = new HttpClient();

PostMethod method = new PostMethod(url);

// method.setRequestHeader(“ContentType”,

// “application/x-www-form-urlencoded;charset=UTF-8”);

method.setRequestBody(data);

// client.getParams()。setContentCharset(“UTF-8”);

client.getParams()。setConnectionManagerTimeout(10000);

try {

client.executeMethod(method);

return method.getResponseBodyAsString();

} catch (Exception e) {

e.printStackTrace();

}

return null;

}

}

java 編寫手機(jī)短信,高手賜教!!!

package examples;

import java.util.Scanner;

public class Entry {

public static void main(String args []) {

Scanner sc=new Scanner(System.in);

String pno,msg;

System.out.print("請(qǐng)輸入短信內(nèi)容:");

msg=sc.nextLine();

System.out.println("請(qǐng)輸入目標(biāo)手機(jī)號(hào)碼:");

pno=sc.nextLine();

ShortMesg newmsg=new ShortMesg();

newmsg.setPhoneNO(pno);

newmsg.setMessage(msg);

SendMesg send=new SendMesg(newmsg);

send.send();

}

}

class ShortMesg {

public ShortMesg() {

}

private String pno,msg;

public void setPhoneNO(String pno) {

this.pno=pno;

}

public String getPhoneNO() {

return this.pno;

}

public void setMessage( String msg) {

this.msg=msg;

}

public String getMessage() {

return this.msg;

}

}

class SendMesg {

private ShortMesg mms;

public SendMesg(ShortMesg mms) {

this.mms=mms;

}

public void send() {

System.out.println("短信內(nèi)容: "+mms.getMessage());

System.out.println("目標(biāo)手機(jī): "+mms.getPhoneNO()+"\n");

}

}

java 如何發(fā)送短信

這段代碼本身只是利用java訪問了一個(gè)url:(",后面帶了一堆的參數(shù):String data = "user_id=" + user_id + "password=" + password +

"mobile_phone=" + mobile_phone +

"msg=" + URLEncoder.encode(msg, "GBK") + "send_date=" + send_date +

"subcode=" + subcode;

,僅此而已,至于具體要怎么發(fā),那就要看這個(gè)URL提供放的后臺(tái)是如何定義參數(shù)的含義了。

java怎么發(fā)送短信

import?java.net.URLEncoder;

import?java.net.URL;

import?java.net.URLConnection;

import?java.util.*;

import?java.io.*;

class?http_post

{?

public?String?send_sms(String?user_id,?String?password,?String?mobile_phone,

String?msg,?String?send_date,?String?subcode)?{

String?ret_str?=?"";

try?{

//?Construct?data

String?data?=?"user_id="?+?user_id?+?"password="?+?password?+

"mobile_phone="?+?mobile_phone?+

"msg="?+?URLEncoder.encode(msg,?"GBK")?+?"send_date="?+?send_date?+

"subcode="?+?subcode;

//?Send?data

URL?url?=?new?URL("");

URLConnection?conn?=?url.openConnection();

conn.setDoOutput(true);

OutputStreamWriter?wr?=?new?OutputStreamWriter(conn.getOutputStream());

wr.write(data);

wr.flush();

//?Get?the?response

BufferedReader?rd?=?new?BufferedReader(new?InputStreamReader(conn.

getInputStream()));

String?line;

while?(?(line?=?rd.readLine())?!=?null)?{

ret_str?+=?line;

}

wr.close();

rd.close();

}

catch?(Exception?e)?{

System.out.println(e.toString());

}

return?ret_str;

}

public?static?void?main(String[]?args)?throws?IOException

{

http_post?http=?new?http_post();

String?ret=http.send_sms("4003","xxxxxxx","13900000000","fromjava中國(guó)萬(wàn)歲","","4003");

System.out.println(ret);

}

}


分享題目:發(fā)短信Java代碼 android發(fā)短信代碼
文章URL:http://weahome.cn/article/hihjhj.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部