Crates.io | messagebird-async |
lib.rs | messagebird-async |
version | 0.5.0 |
source | src |
created_at | 2018-09-12 13:36:13.19482 |
updated_at | 2020-03-19 17:43:09.586311 |
description | Wrapper around the message bird SMS API |
homepage | |
repository | https://github.com/drahnr/messagebird-async |
max_upload_size | |
id | 84359 |
size | 136,432 |
MessageBird is a service for sending SMS at its core https://www.messagebird.com/
Sending a sms to a specified target is implemented in examples/send.rs
:
export MESSAGEBIRD_ACCESSKEY=abio8usad..dfahdk
export SMS_RECIPIENT=1234556
The SMS_RECIPIENT
should NOT contain leading zeros nor the +
. The countrycode is still necessary.
cargo run --example send
or copy & paste:
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate futures;
extern crate messagebird_async;
extern crate tokio_core;
use futures::future::Future;
use messagebird_async::errors::*;
use messagebird_async::sms;
use messagebird_async::sms::*;
fn main() -> Result<(), MessageBirdError> {
env_logger::init();
let msisdn_str = std::env::var("SMS_RECIPIENT".to_string())
.expect("SMS_RECIPIENT should contain the number without prefix");
let msisdn: Msisdn = Msisdn::from_str(msisdn_str.as_str())
.expect("SMS_RECIPIENT did not contain a valid number");
info!("example: sending a message");
let sendable = sms::send::SendParameters::builder()
.payload(
PayloadType::Sms,
Payload::Text("fun".to_string()),
PayloadEncoding::Auto,
)
.origin(AlphaNumeric("inbox".to_string()).into())
.add_recipient(msisdn.into())
//.add_recipient(Recipient::new())
.build();
let accesskey = AccessKey::from_env()?;
let fut = RequestSend::new(&sendable, &accesskey);
let fut = fut.and_then(|sent_msg: Message| {
info!("{:?}", sent_msg);
futures::future::ok(())
});
let mut core = tokio_core::reactor::Core::new().unwrap();
core.run(fut.map(|_| ()))
}
Currently the planned features only include to send SMS and query SMS stati.
crate serde_plain
for trait ToString
and trait FromStr
for objects which are used in query filters and payload www urlencodeSMS
Contacts
(low prio)MMS
(*)Conversation
(*)VoiceMessaging
(*)VoiceCalling
(*)* = not planned, unless external contributors step up
MIT or Apache-2.0
If neither of those work for you, feel free to request so via a github issue.
Since I am not affiliated with MessageBird in any kind (other than being their customer) I'd be delighted if you'd leave a tipp to keep the automated send/receive routines going.