java代码手机发短信 java sms短信接收( 二 )


// 账号
String account = “************************”;
// 密码
String pswd = “************************”;
// 修改为您要发送的手机号,多个用,分割
String mobile = “13*********”;
// 设置您要发送的内容
String msg = “【秒赛科技】您的验证码是:1234”;
// 发短信调用示例
System.out.println(Apis.send(account,pswd, mobile, msg));
}
/**
* 发送短信
*
* @param account
*account
* @param pswd
*pswd
* @param mobile
*手机号码
* @param content
*短信发送内容
*/
public static String send(String account,String pswd, String mobile, String msg) {
NameValuePair[] data = https://www.04ip.com/post/{ 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);
}
/**
【java代码手机发短信 java sms短信接收】* 基于HttpClient的post函数
* PH
* @param url
*提交的URL
*
* @param data
*提交NameValuePair参数
* @return 提交响应
*/
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 如何发送短信这段代码本身只是利用java访问java代码手机发短信了一个url:("java代码手机发短信,后面带了一堆java代码手机发短信的参数:String data = "https://www.04ip.com/post/user_id=" + user_id + "password=" + password +
"mobile_phone=" + mobile_phone +
"msg=" + URLEncoder.encode(msg, "GBK") + "send_date=" + send_date +
"subcode=" + subcode;
,仅此而已,至于具体要怎么发,那就要看这个URL提供放java代码手机发短信的后台是如何定义参数java代码手机发短信的含义了 。
java发送手机短信package com.winhands.quartz;
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机待发短信表
public void work() {
// 任务ID 100001
// 首先查询任务是否正在执行
// 查询列表
TaskInfo taskInfo = new TaskInfo();
taskInfo.setTask_id("100001");
try {
taskInfo = (TaskInfo) baseService.queryForObject("sms_send.queryTaskStatus", taskInfo);
//如果状态是处室状态则执行,否则此次任务不执行

推荐阅读