Skip to content

Instantly share code, notes, and snippets.

@ryanburnette ryanburnette/index.js
Last active Mar 23, 2019

Embed
What would you like to do?
thoughts about integrating akismet api w/ my express-based form endpoints
var akismet = require('akismet-api');
var client = akismet.client({
key: process.env.AKISMET_API_KEY,
blog: process.env.AKISMET_BLOG_URL
});
module.exports = client;
// verify akismet api key
client.verifyKey()
.then(function(valid) {
if (valid) {
console.log('Valid key!');
}
else {
console.log('Invalid key!');
}
})
.catch(function(err) {
console.log('Check failed: ' + err.message);
});
// check for spam in form submission
client.checkSpam({
user_ip : '123.123.123.123', // Required!
user_agent : 'MyUserAgent 1.0 Webkit', // Required!
referrer : req.headers.HTTP_REFERER, // Required!
permalink : 'https://myblog.com/myPost',
comment_type : 'contact-form',
comment_author : 'John Smith',
comment_author_email : 'john.smith@gmail.com',
comment_content : 'Very nice blog! Check out mine!'
}).then(function (err,spam) {
})
catch(function (err) {
}).;
client.submitSpam({
user_ip : '123.123.123.123', // Required!
user_agent : 'MyUserAgent 1.0 Webkit', // Required!
referrer : 'https://google.com', // Required!
permalink : 'https://myblog.com/myPost',
comment_type : 'comment',
comment_author : 'John Smith',
comment_author_email : 'john.smith@gmail.com',
comment_author_url : 'https://johnsblog.com',
comment_content : 'Very nice blog! Check out mine!',
is_test : true // Default value is false
}, function(err) {
if (!err) {
console.log('Spam reported!');
}
});
client.submitHam({
user_ip : '123.123.123.123', // Required!
user_agent : 'MyUserAgent 1.0 Webkit', // Required!
referrer : 'https://google.com', // Required!
permalink : 'https://myblog.com/myPost',
comment_type : 'comment',
comment_author : 'John Smith',
comment_author_email : 'john.smith@gmail.com',
comment_author_url : 'https://johnsblog.com',
comment_content : 'Very nice blog! Check out mine!',
is_test : true // Default value is false
}, function(err) {
if (!err) {
console.log('Non-spam reported!');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.