Crates.io | instant-akismet |
lib.rs | instant-akismet |
version | 0.2.0 |
source | src |
created_at | 2022-09-21 21:31:44.372149 |
updated_at | 2024-04-08 09:08:23.852247 |
description | Rust client for Akismet spam protection |
homepage | https://github.com/InstantDomain/instant-akismet |
repository | https://github.com/InstantDomain/instant-akismet |
max_upload_size | |
id | 671195 |
size | 37,040 |
Instant Akismet is a full set of Rust bindings for the Akismet spam-detection service and is used in production over at Instant Domains to help us protect our users' sites from comment and messaging spam.
To begin with, you'll need to head over to Akismet and join the developer program to obtain an API key.
Note: In order to run the included tests, this key should be set as AKISMET_KEY in your environment.
// Initialize client
let akismet_client = AkismetClient::new(
String::from("https://exampleblog.com"), // The URL for your blog
akismet_key, // Your Akismet API key
reqwest::Client::new(), // Reqwest client to use for requests
AkismetOptions::default(), // AkismetOptions config
);
// Verify key
akismet_client.verify_key().await?;
// Create a comment
let comment = Comment::new(akismet_client.blog.as_ref(), "8.8.8.8")
.comment_author("exampleUser1")
.comment_author_email("example-user@example.com")
.comment_content("example comment content");
// Check comment for spam
let is_spam = akismet_client.check_comment(comment).await?;
In order to run the included tests, you will need to ensure that you have your API key set as AKISMET_KEY in your environment.
cargo test