Crates.io | alibaba-cloud-sdk-rust |
lib.rs | alibaba-cloud-sdk-rust |
version | 0.1.15 |
source | src |
created_at | 2022-05-19 10:41:25.88436 |
updated_at | 2024-11-07 03:17:57.843814 |
description | Alibaba Cloud SDK for Rust |
homepage | https://github.com/wandercn/alibaba-cloud-sdk-rust |
repository | https://github.com/wandercn/alibaba-cloud-sdk-rust |
max_upload_size | |
id | 589644 |
size | 43,752 |
阿里云短信rust sdk
use alibaba_cloud_sdk_rust::services::dysmsapi;
use gostd::strings;
const AliyunSmsServerRegion: &str = "cn-hangzhou";
const AliyunSmsAccessKeyID: &str = "LTAI4FwqPxiAxxxxxx";
const AliyunSmsAccessKeySecret: &str = "xxxxx0FJqHTTLwDUuhxxxxx";
const AliyunSmsReportTempleateCode: &str = "SMS_226xxxx"; // 通知模版
const AliyunSmsSignName: &str = "阿里云"; // 短信署名
fn main()->Result<(), std::io::Error>{
let phoneNumber="1391212xxxx";
match SendSMS(phoneNumber) {
Ok(response)=> println!("{:?}",response),
Err(err)=>println!("{}",err),
}
}
fn SendSMS(phoneNumber: &str) -> Result<(), std::io::Error> {
let mut client = dysmsapi::Client::NewClientWithAccessKey(
AliyunSmsServerRegion,
AliyunSmsAccessKeyID,
AliyunSmsAccessKeySecret,
)?;
let mut request = dysmsapi::CreateSendSmsRequest();
request.PhoneNumbers = strings::Replace(phoneNumber, "+86", "", -1);
request.SignName = AliyunSmsSignName.to_owned();
request.TemplateCode = AliyunSmsReportTempleateCode.to_owned();
let response = client.SendSms(&mut request)?;
println!("{:?}", &response);
Ok(())
}
If you like my open source project and would like to support me, you can donate through the following methods:
DHbDfZWTYjpiGctAyYy1F9YzViTfVRW6aY
limiao2008@gmail.com
0x74682cbE11De154E38D8B220ba177c28481F41a8
paypal.me/wandercn
Thank you for your support!