#sms #tencent #send

simple-tencent-sms

两行代码实现腾讯云短信发送

3 releases

0.1.2 Nov 5, 2024
0.1.1 Nov 5, 2024
0.1.0 Nov 5, 2024

#3 in #tencent

31 downloads per month

MIT license

11KB
182 lines

🚀 安装

cargo add simple-tencent-sms

💡 使用

secret 获取相关可查看腾讯云官网文档

    let tencent_sms = TencentSMS::new(
        "secret_id".into(),
        "secret_key".into(),
        "sms_app_id".into(),
    );

📲 发送短信

    let response_json = tencent_sms
        .send_sms(
            Region::Beijing,
            "sign_name".into(),
            vec!["+86xxxxxxx"],
            "template_id".into(),
            vec!["xxxx"],
        )
        .await?;

response 和官方文档返回json一致

{
    "Response": {
        "SendStatusSet": [
            {
                "SerialNo": "5000:1045710669157053657849499619",
                "PhoneNumber": "+8618501234444",
                "Fee": 1,
                "SessionContext": "outsid_1729495320_1011",
                "Code": "Ok",
                "Message": "send success",
                "IsoCode": "CN"
            }
        ],
        "RequestId": "a0aabda6-cf91-4f3e-a81f-9198114a2279"
    }
}

Dependencies

~8–19MB
~257K SLoC