https://github.com/juggernaut/twilio_rust
A rust-lang client library for Twilio based on hyper
https://github.com/juggernaut/twilio_rust
async rust rust-lang twilio
Last synced: about 1 year ago
JSON representation
A rust-lang client library for Twilio based on hyper
- Host: GitHub
- URL: https://github.com/juggernaut/twilio_rust
- Owner: juggernaut
- License: apache-2.0
- Created: 2017-12-03T01:58:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-03T21:39:56.000Z (over 8 years ago)
- Last Synced: 2025-04-18T13:22:04.472Z (about 1 year ago)
- Topics: async, rust, rust-lang, twilio
- Language: Rust
- Size: 39.1 KB
- Stars: 12
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# twilio_rust
A rust-lang client library for Twilio based on [hyper.rs](https://hyper.rs/). As such, network I/O is done asynchronously
and all results are returned as futures.
# Getting started
Let's start with an example of sending an SMS (You can run this example with `cargo run --example send_message`).
You will need your Twilio credentials first:
```bash
export ACCOUNT_SID=
export AUTH_TOKEN=
```
To send an SMS, you will also need a "from" number i.e a valid callerId in your Twilio accout, and the "to" number i.e the number you want to send the message to:
```bash
export FROM_NUMBER=
export TO_NUMBER=
```
```rust
let from_num = env::var("FROM_NUMBER").expect("FROM_NUMBER must be set to a valid caller ID for your account");
let to_num = env::var("TO_NUMBER").expect("TO_NUMBER must be set to the number you want to send the message to");
// Create the tokio event loop
let mut core = Core::new().unwrap();
// Create the twilio client
let client = Client::new_from_env(&core.handle()).unwrap();
let messages = Messages::new(&client);
// Create the outbound SMS
let outbound_sms = OutboundMessageBuilder::new_sms(
MessageFrom::From(&from_num),
&to_num,
"Hello from Rust!"
).build();
let work = messages.send_message(&outbound_sms);
let sms = core.run(work).unwrap();
println!("Queued outbound SMS {}", sms.sid);
```