Exemple Rust


extern crate reqwest;
#[macro_use]
extern crate serde_json;

use reqwest::Client;

fn main() -> Result<(), reqwest::Error> {

    let payload = json!({
        "sms": {
            "message": {
                "text": "Hello Rust !",
                "sender": "Rust",
            },
            "recipients": {
                "gsm":[
                    {
                        "value": "33612345678",
                    }
                ]
            }
        }
    });

    println!("{}", payload.to_string());

    let request_url = "https://api.smsvendor.com/send";
    let token = "your.token"; //Your first token must be generated on our plateform at https://secure.smsvendor.com/token.html
    let response = Client::new()
        .post(request_url)
        .header("Accept", "application/json")
        .header("Authorization", format!("{}{}", "Bearer ", token))
        .json(&payload)
        .send()?
        .text()?;

    println!("{:#?}", response);

    Ok(())
}