云片的群发短信群发有效果吗

Voice Verification Code
Verification code by fixed phone calling, avoiding the blind area of
prevent scalping,Voice information is harder to being stolen
Analysis of business scenarios
Voice verification code is more secure, prevent scalping
Making concerted efforts to serve 100% users
100% Arrival Rate
Free from the blind area of SMS
Unlimited calls and supporting mass concurrent
Voice information is harder to being stolen
Package service price
Voice call charging,The balance never expires.
Prepay no less than RMB 50 Yuan
Accumulative amount over RMB5,000 Yuan
SMS sending amount monthly over 100,000
Voice call(yuan/count)
Contact Account Manager
Voice call(yuan/count)
Prepay no less than RMB 50 Yuan
Accumulative amount over RMB5,000 Yuan
SMS sending amount monthly over 100,000
Contact Account Manager
Starting to connect to YunPian
First, please sign up for a YunPian account.
Take 1 minute to verify your developer information.
View the API file and get ready for connections.
Now you may use the YunPian services easily!Have any questions?
Support https/IP whitelist/Exception monitoring
Perfection
Perfect filtering mechanism/APIs can
satisfy all of your demand.
Easy access: only four steps/Self-service charge/Self-service invoice
User Guide
Phone: +86-571-
{{ $t("kefu.server1001") }}x
{{ $t("kefu.server1003") }} {{ $t("kefu.server1005") }}
{{ $t("kefu.server1006") }}
{{ $t("kefu.server1008") }}
{{ $t("kefu.server1009") }}
{{ $t("kefu.server1011") }}{{ $t("kefu.server1013") }}
{{ $t("kefu.server1015") }}
{{ $t("kefu.server1017") }}
{{ $t("kefu.server1020") }}
{{ $t("kefu.server1021") }}
{{ $t("kefu.server1023") }}
{{ $t("kefu.server1026") }}
{{ $t("kefu.server1028") }}
{{ $t("kefu.server1029") }}
{{ $t("kefu.server1031") }}
{{ $t("kefu.server1032") }}
{{ $t("kefu.server1033") }}
{{ $t("kefu.server1034") }}
{{ $t("kefu.server1035") }}
400-089-26173844人阅读
java(45)
最近做的这个项目是一个类似于众筹的网站,众所周知,现在主流的网站都会涉及到注册验证码的发送以及验证,购买商品以及送礼这些都可能会有短信的提醒,那么这些短信都是怎么实现的呢?这个项目中需要实现验证码以及购买商品的短信提醒,最近研究了一下,下面把学习成果简略记录一下,以防以后忘记:
一、首先需要在云片网注册一个号码,网站链接:,当然这个网站是要收费的,在这个网站上可以定义模板,也就是你需要发的短信的样式,如下图:
二、有个云片网的模板后,就需要在项目中写接口了,下面上代码:
首先需要引入云片网的API,这些代码可以上云片网中API文档中找,如下代码:
import java.io.IOE
import mons.httpclient.HttpC
import mons.httpclient.HttpM
import mons.httpclient.NameValueP
import mons.httpclient.methods.GetM
import mons.httpclient.methods.PostM
import mons.httpclient.params.HttpMethodP
* 短信http接口的java代码调用示例
* @author jacky
public class JavaSmsApi {
* 服务http地址
private static String BASE_URI = &&;
* 服务版本号
private static String VERSION = &v1&;
* 编码格式
private static String ENCODING = &UTF-8&;
* 查账户信息的http地址
private static String URI_GET_USER_INFO = BASE_URI + &/& + VERSION + &/user/get.json&;
* 通用发送接口的http地址
private static String URI_SEND_SMS = BASE_URI + &/& + VERSION + &/sms/send.json&;
* 模板发送接口的http地址
private static String URI_TPL_SEND_SMS = BASE_URI + &/& + VERSION + &/sms/tpl_send.json&;
* 取账户信息
* @return json格式字符串
* @throws IOException
public static String getUserInfo(String apikey) throws IOException{
HttpClient client = new HttpClient();
HttpMethod method = new GetMethod(URI_GET_USER_INFO+&?apikey=&+apikey);
HttpMethodParams param = method.getParams();
param.setContentCharset(ENCODING);
client.executeMethod(method);
return method.getResponseBodyAsString();
* @param apikey apikey
* @param text 短信内容 
* @param mobile 接受的手机号
* @return json格式字符串
* @throws IOException
public static String sendSms(String apikey, String text, String mobile) throws IOException{
HttpClient client = new HttpClient();
NameValuePair[] nameValuePairs = new NameValuePair[3];
nameValuePairs[0] = new NameValuePair(&apikey&, apikey);
nameValuePairs[1] = new NameValuePair(&text&, text);
nameValuePairs[2] = new NameValuePair(&mobile&, mobile);
PostMethod method = new PostMethod(URI_SEND_SMS);
method.setRequestBody(nameValuePairs);
HttpMethodParams param = method.getParams();
param.setContentCharset(ENCODING);
client.executeMethod(method);
return method.getResponseBodyAsString();
* 通过模板发送短信
* @param apikey apikey
* @param tpl_id 模板id
* @param tpl_value 模板变量值 
* @param mobile 接受的手机号
* @return json格式字符串
* @throws IOException
public static String tplSendSms(String apikey, long tpl_id, String tpl_value, String mobile) throws IOException{
HttpClient client = new HttpClient();
NameValuePair[] nameValuePairs = new NameValuePair[4];
nameValuePairs[0] = new NameValuePair(&apikey&, apikey);
nameValuePairs[1] = new NameValuePair(&tpl_id&, String.valueOf(tpl_id));
nameValuePairs[2] = new NameValuePair(&tpl_value&, tpl_value);
nameValuePairs[3] = new NameValuePair(&mobile&, mobile);
PostMethod method = new PostMethod(URI_TPL_SEND_SMS);
method.setRequestBody(nameValuePairs);
HttpMethodParams param = method.getParams();
param.setContentCharset(ENCODING);
client.executeMethod(method);
return method.getResponseBodyAsString();
public static void main(String[] args) throws IOException {
//修改为您的apikey
String apikey = &xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&;
//修改为您要发送的手机号
String mobile = &188xxxxxxxx&;
/**************** 查账户信息调用示例 *****************/
System.out.println(JavaSmsApi.getUserInfo(apikey));
/**************** 使用通用接口发短信 *****************/
//设置您要发送的内容
String text = &您的验证码是1234【云片网】&;
//发短信调用示例
System.out.println(JavaSmsApi.sendSms(apikey, text, mobile));
/**************** 使用模板接口发短信 *****************/
//设置模板ID,如使用1号模板:您的验证码是#code#【#company#】
long tpl_id=1;
//设置对应的模板变量值
String tpl_value=&#code#=1234&#company#=云片网&;
//模板发送的调用示例
System.out.println(JavaSmsApi.tplSendSms(apikey, tpl_id, tpl_value, mobile));
然后就是在自己的接口中调用短信接API,如下面发送验证码的接口:
@RequestMapping(value = &/text/send&, method = RequestMethod.GET)
public ResponseEntity&?& registSendMobile(@RequestParam(value = &loginName&, required = true)String loginName) throws IOException {
Map&String, Object& map = Maps.newHashMap();
String text = String.valueOf(Math.random()).substring(2,8);
String value = &#code#=&+
String res = textMessageService.tplSendSms(value, loginName, TextMessageService.SEND_VERIFICATION_CODE);
text = MD5Util.MD5(text);//MD5加密
map.put(&code&, text);
return new ResponseEntity(map, HttpStatus.OK);
这里用到的tplSendSms()方法就是调用的短信API中的方法,其中value是需要传的参数,这里如果有两个及以上的参数,需要用&隔开,如下:
String value = &#user#=&+coupon.getUser().getName()+&#msg#=&+coupon.getMemo()+&,&+coupon.getCouponNo();loginName|其实就是所发短信的电话号码,然后最后一个参数是云片网的模板参数。
这是直接在接口中直接调用短信接口和模板,还有一种方法是在接口中写一个触发方法,当我们监测到执行了触发方法后就开始调用短信接口和模板,继续上代码:
首先是接口代码:
//发送短信,用于短信发送的触发
presentService.sendMail(projectSupport, oldUser,newUser);
然后,调用发送短信API的代码,这里面要获取所要传的参数,其中参数要中#括起来,如#code#:
@AfterReturning(&execution(*
com.thon.service.user.PresentService.sendMail(..))&)
public void sendPresentTextAndMessage(JoinPoint jp) throws IOException {
ProjectSupport ps = (ProjectSupport)jp.getArgs()[0];
User user = (User)jp.getArgs()[1];
User newUser = (User)jp.getArgs()[2];
ps = projectSupportService.getProjectSupport(ps.getId());
Project projectSupport = project
User from = userService.getUserByEmail(Global.getConfig(&service.user&));
User to = userService.getUser(user.getId());
String text = &亲爱的&+to.getName()+&,&+newUser.getName()+&向您赠送了&+ps.getProduct().getName();
messageService.sendMessage(from, to, text);
//String value =
&#user1#=&+ps.getUserName()+&&&+&#user2#=&+to.getName()+&&&+&#goods=#&+ps.getProduct().getName();
String text2 = String.valueOf(Math.random()).substring(2,8);
String value = &#code#=&+text2;
String loginName = user.getLoginName();
textMessageService.tplSendSms(value, loginName, TextMessageService.SEND_VERIFICATION_CODE);
//textMessageService.tplSendSms(value, to.getLoginName(), TextMessageService.SEND_PRESENT_MESSAGE);
}其中的第一行代码就是监测sendMali()方法是否执行,如果执行,就是进入下面的接口。
总结:以上就是项目中实现短信的发送的一个简略流程,短信模板的好处就在于把短信发送与开发者分开了,我们只需要写接口传入所需正确的参数,调用模板就可以实现短信的发送了。
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:67110次
积分:1431
积分:1431
排名:千里之外
原创:71篇
转载:23篇
评论:13条
(1)(3)(5)(2)(3)(5)(5)(4)(1)(4)(14)(9)(9)(14)(5)(7)(1)(2)&&&查看内容
查看: 8807
此接口只使用好商城 版本
查看模板请回复哦:
游客,如果您要查看本帖隐藏内容请
QQ截图11.png (60.41 KB, 下载次数: 6)
00:32 上传
本文地址 :
本文标题 :
, 积分 54, 距离下一级还需 46 积分
发表于 6&天前
昂我给我你给我个
, 积分 104, 距离下一级还需 396 积分
, 积分 220, 距离下一级还需 280 积分
这个是所有版本都通用的吗?
, 积分 106, 距离下一级还需 394 积分
, 积分 133, 距离下一级还需 367 积分
支持,挺好的
, 积分 142, 距离下一级还需 358 积分
xiaowen350
需要用一下
此接口只使用好商城 版本
, 积分 146, 距离下一级还需 354 积分
要查看本帖
, 积分 114, 距离下一级还需 386 积分
很需要,谢谢佻
01020304050607080910
好商城()只作为ShopNC B2B2C商城系统爱好者的技术交流平台主要提供SHOPNC B2B2C 技术服务及二次开发,包括但不限于:修复ShopNC B2B2C的BUG、开发ShopNC B2B2C插件、美化ShopNC B2B2C模板等。如有商业用途,请购买正版ShopNC商城系统。
Copyright @
粤ICP备号-3

我要回帖

更多关于 短信群发 的文章

 

随机推荐