云信 短信发送 demo
package com.dataTaskListener;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod; //全文模板发送
public class SendMsg{
public static String sendMSM(String phone,String number){
try {
HttpClient client = new HttpClient();
PostMethod post = new PostMethod("http://api.sms.cn/sms/");
post.addRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");//在头文件中设置转码
NameValuePair[] data ={ new NameValuePair("ac", "send"),new NameValuePair("uid", ""),new NameValuePair("pwd", ""),new NameValuePair("mobile",phone),
new NameValuePair("encode","utf8"),new NameValuePair("template",""),new NameValuePair("content","{\"number\":\""+number+"\"}")};
post.setRequestBody(data);
client.executeMethod(post);
Header[] headers = post.getResponseHeaders();
int statusCode = post.getStatusCode();
//System.out.println("statusCode:"+statusCode);
for(Header h : headers){
//System.out.println(h.toString());
}
String result = new String(post.getResponseBodyAsString().getBytes("utf-8")); //返回信息
//System.out.println(result); //打印返回消息状态
post.releaseConnection();
return result;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
云信 短信发送 demo的更多相关文章
- 2018阿里云短信发送DEMO接入简单实例
以下更新2018-04-2309:57:54 后续不再更新, 基本类: app/SignatureHelper.php <?php namespace aliyun_mns; /** * 签名助 ...
- ASP版_阿里大于短信API Demo
阿里大于申请地址:http://www.alidayu.com 阿里大于短信发送Demo: ******index.asp************* <%@LANGUAGE="VBSC ...
- 短信发送接口demo
public class SendValidCode { // 短信发送的接口网关 private static String sendUrl = "******************** ...
- thinkphp 5.0整合阿里大于验证码短信发送接口,含完整模型验证实例DEMO
为大家分享一个阿里大于短信发送接口: 首先创建一个发送模型(Send.php): <?php namespace app\index\model; use think\Validate; cla ...
- C# 短信发送 邮件发送
兴趣是最好的老师. --爱因斯坦 一.实现短信发送 1.使用短信mao的方式进行短信发送,前提要购买硬件设备,这里就不考虑展示了: 2.使用中国网建提供的短信平台,但是用几次后要收费: 我们这里主要介 ...
- PHP接入阿里云市场 阿里短信服务DEMO
阿里短信服务:支持三大运营商短信.智能管道等优质能力,产品特点:3秒可达.99%到达率.超低资费. 使用阿里短信服务步骤: 1.购买服务 到https://market.aliyun.com/prod ...
- spring boot集成阿里云短信发送接收短信回复功能
1.集成阿里云通信发送短信: 在pom.xml文件里添加依赖 <!--阿里短信服务--> <dependency> <groupId>com.aliyun</ ...
- jssip音视频及短信开发demo(中文注释完整版)
完整案例demo下载地址:http://download.csdn.net/download/qq_39421580/10214712 <!DOCTYPE html> <html l ...
- Java版阿里云通信短信发送API接口实例(新)
阿里云通信(原名阿里大于)的短信服务(Short Message Service)是阿里云为用户提供的一种通信服务的能力,支持快速发送短信验证码.短信通知等. 完美支撑双11期间2亿用户,发送6亿短信 ...
随机推荐
- windows 下安装mysql 成功版
mysql 下载地址 http://dev.mysql.com/downloads/ zip版下载 解压到本地 假设文件保存在C:\mysql-5.7.17-winx64 1.以管理员身份运行cmd. ...
- js中的数组遍历
js中的数组遍历是项目中经常用到的,在这里将几种方法做个对比. ! for循环:使用评率最高,也是最基本的一种遍历方式. let arr = ['a','b','c','d','e']; for (l ...
- es5、es6函数调用
ES5中函数的4种调用 在ES5中函数内容的this指向和调用方法有关 1 函数调用模式 包括函数名()和匿名函数调用,this指向window function getSum() { console ...
- 认识计算机操作系统(day01)
一.计算机的框架 什么是操作系统?(汽车) 加油系统 油门 用户跟加油子系统交互的窗口.(接口) 方向系统 方向盘 用户跟方向系统的交互接口. 导航系统 ... 汽车的操作系统有很多的子系统来完成.这 ...
- (C/C++学习)2.C语言中文件流操作基本函数总结
函数所在头文件:stdio.h 说明:前半部分主要为对各个文件流操作函数的例举,后半部分着重于上机运行分析.文中部分引用自王桂林老师的C/C++课件. 1.FIELE *fopen(const cha ...
- Ubuntu Server下docker实战 02: docker进阶配置
在上一篇文章里<Ubuntu Server下docker实战 01: 安装docker>,我们已经把docker安装起来了,并运行了一个hello-world 这一篇,我们继续讲进阶配置. ...
- 49.filter、query比较
主要知识点 1.filter与query用在同一次查询中的语法 2.filter与query使用场景对比 3.二都的性能比较 一.filter与query示例 1.先准备数据 PUT /com ...
- 洛谷11月月赛(284pts rank85)
https://www.luogu.org/contestnew/show/12006 我是比赛完后在去写的 这是我第一次打洛谷月赛,之前一次是比赛完才去看而且写了第一题就没写后面的了 284分,太水 ...
- 单元测试代码:SpringTest+JUnit
/** * JUnit单元测试父类,配置了Spring的基础环境. <br/> * 可以作为Controller.Service.Dao单元测试的父类. * * @author leiwe ...
- C#关键字的个人理解与注释
C#关键字注释:abstract:抽象as:类型转换(返回转换结果)base:基类bool:布尔类型break:条件中断语句byte:字节case:条件语句catch:异常捕获后执行char:16 位 ...