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

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

相关推荐

  • 阿里云数据库备份删除

    如何清除云服务的所有数据 苹果云服务icloud数据的方法:1、打开手机的桌面。2、进入设置,找到iCloud。3、点击储存与备份。4、然后选择管理储存空间。5、点击想要删除的数据,然后再选择最下方的”删除备份”即可删除。 使用阿里云数据库误删了了数据怎么恢复 展开全部可快照回滚恢复数据。很方便的。。 如何擦除阿里云服务器数据 格式化…

    2023年8月29日
    64800
  • 宜宾阿里云代理商:阿里云网站防护如何

    阿里云的网站防护服务涵盖了多个方面,包括以下几个重要的方面: DDoS攻击防护:阿里云提供两种类型的DDoS攻击防护,分别是基础防护和高级防护。基础防护为所有用户免费提供,可以抵御大多数的DDoS攻击;高级防护则提供更强大的防护能力,可以抵御更复杂、更大规模的DDoS攻击。 Web应用防火墙(WAF):阿里云的WAF服务可以对网站进行实时监控和防御,可以防护…

    2023年12月14日
    65200
  • 阿里云开设数据中心的条件

    云计算发展对数据中心和设备有哪些新要求 1、大规模为了支撑大规模的云客户访问和使用,与传统的数据中心相比,云计算数据中心需拥有较大的服务器规模,将数个甚至数十个传统规模数据中心集中整合,进行集中化数据备份、计算和管理,才能实现云业务所需的计算能力。2、高密度云计算是一种集中化的部署方式,数据量和计算量的爆发式增长决定了单机柜中服务器的功率密度大大增加,单个服…

    2023年8月28日
    80200
  • 开闲鱼店铺影响阿里巴巴云客服报名吗

    开闲鱼店铺不会直接影响阿里巴巴云客服报名。开设闲鱼店铺是在阿里巴巴旗下的二手交易平台上进行销售的一种方式,而阿里巴巴云客服是指的阿里巴巴提供的一种在线客服解决方案。阿里巴巴云客服报名通常与店铺经营无关,是一个独立的活动。 然而,如果你拥有开闲鱼店铺的经验,可能会在阿里巴巴云客服报名过程中提供有关自己在电商业务方面的经验和技能,并在评估中获得一定的优势,但这不…

    2023年11月6日
    84900
  • 阿里云国际站注册教程:api请求验证

    打开你的浏览器,输入https://www.alibabacloud.com/并打开阿里云国际网站。 点击右上角的 “Free Account” 按钮开始注册。 输入你的电子邮件地址,点击 “Get Code”来获取验证码;检查你的邮件,输入收到的验证码,然后点击下一步。 设置你的账户名和密码,这将用于登录你的…

    2024年3月23日
    63400

发表回复

登录后才能评论

联系我们

4000-747-360

在线咨询: QQ交谈

邮件:ixuntao@qq.com

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

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