simple-tencent-sms

Crates.iosimple-tencent-sms
lib.rssimple-tencent-sms
version0.1.2
sourcesrc
created_at2024-11-05 05:56:22.263901
updated_at2024-11-05 14:03:58.762111
description两行代码实现腾讯云短信发送
homepage
repositoryhttps://github.com/BaLaLaLs/simple-tencent-sms
max_upload_size
id1436061
size12,103
绮梦 (BaLaLaLs)

documentation

README

🚀 安装

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"
    }
}
Commit count: 6

cargo fmt