Web Requests, Automation and Alerts.
Learn how to send web requests from a Zephyr program.
fn send_message(env: &EnvClient, source: ScVal, amount: ScVal) {
let source = {
let ScVal::Address(address) = source else { panic!() };
address.to_string()
};
let key = env!("DISCORD_API");
let body = format!(
r#"{{"content": "{}"}}"#,
format!(
"New large deposit of {:?} XLM from {} on xycLoans testnet XLM pool.",
amount, source
)
);
env.send_web_request(AgnosticRequest {
body: Some(body),
url: "https://discordapp.com/api/channels/1234475897092968459/messages".into(),
method: zephyr_sdk::Method::Post,
headers: vec![
("Content-Type".into(), "application/json".into()),
("Authorization".into(), format!("Bot {}", key)),
],
})
}Resources
Last updated