Crate yunpian_sdk

source ·
Expand description

This crate offers:

云片 短信发送sdk

Features:

  • 云片5年前提交的sdk已不能使用,特更新了一个

Installation

将所需版本的crate放入dependencies的部分 Cargo.toml:

[dependencies]
yunpian-sdk = "*"

Examples

#[tokio::main]
async fn main() {
    //云片api_key
    let api_key = "xxxxx";
    let sms = yunpian_sdk::Yunpian::new(api_key);
    let text = "【安妮蝶网络】您的验证码为1024,10分钟内有效,请勿泄露。如非本人操作,请忽略本短信。";
    let phone = "18610996705";
    match sms.single_send(text, phone).await{
        Ok(b) => {
            if b == true {
                println!("发送成功")
            }else{
                print!("发送失败")
            }
         },
        Err(e) => {
            println!("err: {}", e)
        }
     };
}

Structs