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

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

相关推荐

  • 阿里云acp云计算实验手册

    云计算运维这一块刚出来需要证书吗 做的大的都开始发行认证了,比如阿里云就有个云计算认证acp 做售前咨询顾问(iaas云计算方向)有前途吗 目前云计算行业的售前对技术技能要求还是比较高的,建议从事这个行业的话,先考取一些含金量高的证书吧,阿里云官方大学有合作伙伴,云顶云是阿里云大学认证合作伙伴,你可以了解看看1阿里云云计算ACP认证2阿里云大数据ACP认证 …

    2023年8月26日
    15600
  • 阿里人工智能开放平台

    阿里人工智能开放平台是由阿里巴巴集团推出的一个人工智能开发者平台。该平台旨在为人工智能开发者和创业者提供技术支持和资源,帮助他们开发和部署人工智能项目。 阿里人工智能开放平台包含了多个人工智能相关的服务和工具,包括自然语言处理、机器学习、图像识别、语音识别等。开发者可以通过这些服务和工具来构建各种人工智能应用,如智能客服、智能推荐、智能语音助手等。 阿里人工…

    2023年9月3日
    16900
  • 阿里云轻量应用服务器香港

    阿里云服务器 香港节点 怎么样 首先阿里云的产品稳定性是毋庸置疑的,就算是香港等其他海外节点稳定性也是不错的,速度方面也是相对来说比较快的,另外在万网互联还能提供各种优惠,可以考虑使用。 阿里云 ecs香港服务器怎么样 阿里云香港节点还可以,为国际带宽,都有正反两面,楼主什么应用,也可以关注影速科技,专业海外云服务。 阿里云香港服务到底怎么样 没有用过但听说…

    2023年8月26日
    18300
  • 菏泽阿里云代理商:api-1-0dll

    菏泽阿里云代理商:api-1-0dll 引言 阿里云是中国领先的云计算服务提供商,拥有广泛的产品线和强大的技术支持。作为菏泽地区的阿里云代理商,我们向您介绍一款优秀的产品:api-1-0dll。 强大的性能和稳定性 阿里云的api-1-0dll具有出色的性能和稳定性,可以满足各种企业级应用的需求。无论是高并发的网站访问还是复杂的数据处理,api-1-0dll…

    2024年1月30日
    16700
  • 常德阿里云代理商:app日志

    阿里云代理商是指在常德地区提供阿里云相关产品和服务代理或销售的机构或个人。其中,app日志是指移动应用程序在运行过程中产生的日志信息。这些日志包含了应用程序的运行状态、用户行为、错误信息等,对于开发者和运维人员来说具有重要的参考价值。 常德阿里云代理商可以帮助客户在使用阿里云的过程中解决各种问题,包括app日志的收集、存储、分析和展示等。代理商可以根据客户的…

    2024年1月9日
    18800

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

联系我们

4000-747-360

在线咨询: QQ交谈

邮件:ixuntao@qq.com

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

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