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的更多相关文章

  1. 2018阿里云短信发送DEMO接入简单实例

    以下更新2018-04-2309:57:54 后续不再更新, 基本类: app/SignatureHelper.php <?php namespace aliyun_mns; /** * 签名助 ...

  2. ASP版_阿里大于短信API Demo

    阿里大于申请地址:http://www.alidayu.com 阿里大于短信发送Demo: ******index.asp************* <%@LANGUAGE="VBSC ...

  3. 短信发送接口demo

    public class SendValidCode { // 短信发送的接口网关 private static String sendUrl = "******************** ...

  4. thinkphp 5.0整合阿里大于验证码短信发送接口,含完整模型验证实例DEMO

    为大家分享一个阿里大于短信发送接口: 首先创建一个发送模型(Send.php): <?php namespace app\index\model; use think\Validate; cla ...

  5. C# 短信发送 邮件发送

    兴趣是最好的老师. --爱因斯坦 一.实现短信发送 1.使用短信mao的方式进行短信发送,前提要购买硬件设备,这里就不考虑展示了: 2.使用中国网建提供的短信平台,但是用几次后要收费: 我们这里主要介 ...

  6. PHP接入阿里云市场 阿里短信服务DEMO

    阿里短信服务:支持三大运营商短信.智能管道等优质能力,产品特点:3秒可达.99%到达率.超低资费. 使用阿里短信服务步骤: 1.购买服务 到https://market.aliyun.com/prod ...

  7. spring boot集成阿里云短信发送接收短信回复功能

    1.集成阿里云通信发送短信: 在pom.xml文件里添加依赖 <!--阿里短信服务--> <dependency> <groupId>com.aliyun</ ...

  8. jssip音视频及短信开发demo(中文注释完整版)

    完整案例demo下载地址:http://download.csdn.net/download/qq_39421580/10214712 <!DOCTYPE html> <html l ...

  9. Java版阿里云通信短信发送API接口实例(新)

    阿里云通信(原名阿里大于)的短信服务(Short Message Service)是阿里云为用户提供的一种通信服务的能力,支持快速发送短信验证码.短信通知等. 完美支撑双11期间2亿用户,发送6亿短信 ...

随机推荐

  1. logging模块-logging.basicConfig、logger.setLevel、handler.setLevel优先级

    logging.basicConfig < handler.setLevel < logger.setLevel 1.脚本中没有配置logger.setLevel会使用handler.se ...

  2. spring cloud(五) hystrix

    开启feign 熔断 hystrix    整合hystrix-dashboard监控面板 1. 服务调用者boot工程 pom引入依赖 <!-- hystrix-dashboard 监控依赖 ...

  3. 解析MYsql写的表达式

    今天遇到个问题,Sql中直接写的是复杂表达式,如何解析呢? round(((0.00579049505+0.00006600324*JING_JIE^2*SHU_GAO-0.00000046921*J ...

  4. nyoj112-指数运算

    指数运算时间限制:600 ms  |  内存限制:65535 KB难度:2描述写一个程序实现指数运算 X^N.(1<X<10,0<N<20)输入输入包含多行数据 每行数据是两个 ...

  5. linux基础随记

    1.cd 切换路径 cd ~vbird 进入这个用户的主目录cd ~ 进入root这个目录下cd .. 进入root上层目录cd - 进入root这个目录下cd /var/spool/mail 直接访 ...

  6. js获取数组中任意一项

    1.获取数组任一项 在一些实际应用场景中,会要求实现一个随机的需求,随机获取某一项,来展示出来,都知道要通过javaScript的Math.random()方法来实现,这里我在Array的原型上添加了 ...

  7. 【codeforces 793B】Igor and his way to work

    [题目链接]:http://codeforces.com/contest/793/problem/B [题意] 给一个n*m大小的方格; 有一些方格可以走,一些不能走; 然后问你从起点到终点,能不能在 ...

  8. owin-startup方法

    owin在根目录下有这个startup.cs文件,里面有个startup方法,这个和global.asax有什么区别呢? 测试一下执行顺序,是先执行了global.asax文件,再执行了startup ...

  9. oracle regexp_like介绍和例子

    oracle regexp_like介绍和例子 学习了:http://www.cnblogs.com/einyboy/archive/2012/08/01/2617606.html ORACLE中的支 ...

  10. [GraphQL] Apollo React Mutation Component

    In this lesson I refactor a React component that utilizes a higher-order component for mutations to ...