厦门阿里云代理商:安卓发送短信完整代码

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class AlibabaCloudSMS {

public static void main(String[] args) {
    String accessKeyId = "your_access_key_id";
    String accessKeySecret = "your_access_key_secret";
    String phoneNumbers = "your_phone_number";
    String signName = "your_sign_name";
    String templateCode = "your_template_code";
    String templateParam = "{"code":"123456"}";

    try {
        String url = "http://dysmsapi.aliyuncs.com/?Action=SendSms"
                + "&PhoneNumbers=" + URLEncoder.encode(phoneNumbers, "UTF-8")
                + "&SignName=" + URLEncoder.encode(signName, "UTF-8")
                + "&TemplateCode=" + URLEncoder.encode(templateCode, "UTF-8")
                + "&TemplateParam=" + URLEncoder.encode(templateParam, "UTF-8")
                + "&AccessKeyId=" + URLEncoder.encode(accessKeyId, "UTF-8")
                + "&SignatureMethod=HMAC-SHA1"
                + "&SignatureNonce=45e25e9b-0a6f-4e51-9c3a-731b488ec5fc"
                + "&SignatureVersion=1.0"
                + "&Timestamp=2018-12-05T23:56:34Z"
                + "&Signature=Signature";

        System.out.println("SMS URL: " + url);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
}

}

import java.io.*;
import java.net.*;
import java.util.*;

厦门阿里云代理商:安卓发送短信完整代码

public class SMSSender {


public static void main(String[] args) {
    String url = "http://api.k780.com:88";
    String appKey = "your_app_key";
    
    Map<String, String> params = new HashMap<>();
    params.put("app", "sms.send");
    params.put("tempid", "your_template_id");
    params.put("sign", "your_sign");
    params.put("appkey", appKey);
    params.put("mobile", "your_mobile_number");
    params.put("content", "your_message_content");
    
    try {
        URL obj = new URL(url);
        HttpURLConnection con = (HttpURLConnection) obj.openConnection();
        con.setRequestMethod("POST");
        con.setDoOutput(true);
        
        DataOutputStream wr = new DataOutputStream(con.getOutputStream());
        wr.writeBytes(getParamsString(params));
        wr.flush();
        wr.close();
        
        BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String inputLine;
        StringBuffer response = new StringBuffer();
        
        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();
        
        System.out.println(response.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

private static String getParamsString(Map<String, String> params) throws UnsupportedEncodingException {
    StringBuilder result = new StringBuilder();
    
    for (Map.Entry<String, String> entry : params.entrySet()) {
        result.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
        result.append("=");
        result.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
        result.append("&");
    }
    
    String resultString = result.toString();
    return resultString.length() > 0 ? resultString.substring(0, resultString.length() - 1) : resultString;
}

}

发布者:luotuoemo,转转请注明出处:https://www.jintuiyun.com/156548.html

(0)
luotuoemo的头像luotuoemo
上一篇 2024年3月3日 03:00
下一篇 2024年3月3日 03:58

相关推荐

  • 芜湖阿里云代理商:access2007如何打开源数据库

    在阿里云上使用Access 2007 打开源数据库的步骤如下: 首先,在阿里云上创建一个Access数据库文件(.accdb或.mdb格式),如果已经有一个数据库文件,可以跳过这一步。 打开Access 2007软件,在“外部数据”选项卡下选择“新建数据源”->“从文件”->“选择数据库”,然后选择你在阿里云上创建的数据库文件。 在弹出窗口中,选…

    2024年1月31日
    37400
  • 襄阳阿里云代理商:安卓 映射网络共享

    襄阳阿里云代理商:安卓映射网络共享 阿里云的优势: 阿里云作为国内领先的云服务提供商,具有以下优势: 稳定可靠:阿里云基于阿里巴巴集团庞大的云计算和数据中心设施,提供稳定可靠的云服务。用户无需担心由于网络环境的变化而导致的连接中断或性能下降。 快速部署:阿里云提供高效的资源分配和管理工具,使用户可以快速部署和配置网络共享。无需繁琐的设置和复杂的步骤,只需几分…

    2024年1月12日
    40500
  • 阿里云服务器数据迁移到新的服务器 额外收费

    我公司在阿里云买了服务器,现在要换一台服务器,我把旧的数据导入了新的服务器里,现在显示正在运行中 只要可以正常使用就没问题的了。如果是网站服务器,可以试试网站能否正常访问。如果是数据库服务器,可以试试数据查询写入是否正常。如果都没问题,就ok了。 阿里云负载均衡另一台云服务器可以是按流量收费么 小鸟云的可以。按需取用,按需付费,降低投入成本。具体的就问下他们…

    2023年8月28日
    35500
  • 湛江阿里云企业邮箱代理商:阿里云ecs搭建网站

    湛江阿里云企业邮箱代理商:阿里云ecs搭建网站 阿里云企业邮箱优势 阿里云企业邮箱是由阿里云推出的一款专业、安全、稳定的企业邮箱服务,拥有强大的防垃圾邮件功能、高可靠性和灵活的管理权限,可以为企业提供高效的团队协作和沟通解决方案。 阿里云ecs搭建网站 阿里云ecs是阿里云提供的云服务器服务,可以通过ecs快速搭建网站,实现网站的部署和运行。ecs具有高性能…

    2024年2月26日
    39300
  • 阿里云企业邮箱:如何设置阿里云邮件标签?

    阿里云企业邮箱:如何设置邮件标签及代理商优势解析 一、邮件标签的作用与价值 在高效的企业沟通中,邮件分类管理至关重要。阿里云企业邮箱提供的邮件标签功能,允许用户通过自定义标签对邮件进行多维归类,例如按项目、优先级或部门划分,从而快速定位关键信息,提升工作效率。 二、阿里云企业邮箱设置邮件标签的步骤 登录邮箱账户:访问阿里云企业邮箱Web端,输入管理员或成员账…

    2025年7月30日
    26200

发表回复

登录后才能评论

联系我们

4000-747-360

在线咨询: QQ交谈

邮件:ixuntao@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
购买阿里云服务器请访问:https://www.4526.cn/