开发者社区> 问答> 正文

Java怎样实现短信发送与接收呢?

最近需要在程序里实现短信发送与接收,应该怎样实现呢?求大神指教啊

展开
收起
蛮大人123 2016-06-12 18:02:20 3702 0
1 条回答
写回答
取消 提交回答
  • 我说我不帅他们就打我,还说我虚伪
     //官网的URL
            String url="http://gw.api.taobao.com/router/rest";
            //成为开发者,创建应用后系统自动生成
            String appkey="23300902";
            String secret="24c5befb62bed7917bf139b7d39d251d";
            //短信模板的内容
            String json="{\"code\":\"1234\",\"product\":\"某某电子商务验证\"}";
            TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
            req.setExtend("123456");
            req.setSmsType("normal");
            req.setSmsFreeSignName("变更验证");
            req.setSmsParamString(json);
            req.setRecNum(tel);
            req.setSmsTemplateCode("SMS_4720619");
            try {
                AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
                System.out.println(rsp.getBody());
                return 1;
            } catch (Exception e) {
                // TODO: handle exception
                return -1;
            }
    2019-07-17 19:34:51
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载