Akismet for Kotlin/Java/Android, a client library for accessing the Automattic Kismet (Akismet) spam comments filtering service. https://github.com/ethauvin/akismet-kotlin
Find a file
2019-09-23 18:31:28 -07:00
.circleci Fix for CircleCI, maybe. 2019-09-23 15:06:43 -07:00
.idea Fixed typo. 2019-09-19 12:31:42 -07:00
config Added package documentation. 2019-09-19 18:07:05 -07:00
examples Cleanup. 2019-09-23 18:31:17 -07:00
gradle/wrapper Initial commit. 2019-09-18 05:16:01 -07:00
src Cleanup. 2019-09-23 18:31:17 -07:00
.editorconfig Initial commit. 2019-09-18 05:16:01 -07:00
.gitattributes Initial commit. 2019-09-18 05:16:01 -07:00
.gitignore Initial commit. 2019-09-18 05:16:01 -07:00
.travis.yml Added CI configs. 2019-09-23 14:57:06 -07:00
build.gradle.kts Workaroud Dokka issue on Windows 2019-09-23 14:07:56 -07:00
detekt-baseline.xml Implemented errorMessage and JSON (de)serialization. 2019-09-22 12:03:53 -07:00
gradlew Fix for CircleCI, maybe. 2019-09-23 15:06:43 -07:00
gradlew.bat Initial commit. 2019-09-18 05:16:01 -07:00
LICENSE.txt Added license. 2019-09-20 01:09:01 -07:00
pom.xml Implemented appUserAgent instead of application name/version. 2019-09-22 22:52:41 -07:00
README.md The basics for now. 2019-09-23 18:31:28 -07:00
settings.gradle.kts Initial commit. 2019-09-18 05:16:01 -07:00
version.mustache Added version template. 2019-09-19 18:07:38 -07:00
version.properties Initial commit. 2019-09-18 05:16:01 -07:00

License (3-Clause BSD)
Known Vulnerabilities Quality Gate Status Build Status CircleCI

Akismet for Kotlin/Java

Akismet for Kotlin/Java is a pretty complete and straightforward implementation of the Automattic's Akismet API, a free service that can be used to actively stop comments spam.

Examples

Kotlin

val akismet = Akismet("YOUR_API_KEY", "YOUR_BLOG_URL")
val comment = AkismetComment(userIp = "127.0.0.1", userAgent = "curl/7.29.0")

comment.setReferrer("http://www.google.com");
comment.setType(AkismetComment.TYPE_COMMENT);
comment.setAuthor("admin");
comment.setAuthorEmail("test@test.com");
comment.setAuthorUrl("http://www.CheckOutMyCoolSite.com");
comment.setDateGmt(Akismet.dateToGmt(new Date()));
comment.setContent("It means a lot that you would take the time to review our software.");

val isSpam = akismet.checkComment(comment)
if (isSpam) {
    // ...
}

Java

final Akismet akismet = new Akismet("YOUR_API_KEY", "YOUR_BLOG_URL");
final AkismetComment comment = new AkismetComment("127.0.0.1", "curl/7.29.0");

comment.setReferrer("http://www.google.com");
comment.setType(AkismetComment.TYPE_COMMENT);
comment.setAuthor("admin");
comment.setAuthorEmail("test@test.com");
comment.setAuthorUrl("http://www.CheckOutMyCoolSite.com");
comment.setDateGmt(Akismet.dateToGmt(new Date()));
comment.setContent("It means a lot that you would take the time to review our software.");

final boolean isSpam = akismet.checkComment(comment);
if (isSpam) {
    // ...
}

HttpServletRequest

The more information is sent to Akismet, the more accurate the response is. An HttpServletRequest can be used as a parameter so that all of the relevant information is automatically included.

AkismetComment(request = context.getRequest())

This will ensure that the user's IP, agent, referrer and various environment variables are automatically extracted from the request.

JSON

Since comments mis-identified as spam or ham can be submitted to Askimet to improve the service. A comment can be saved as a JSON object to be stored in a database, etc.

var json = comment.toString()

At a latter time, the comment can the be submitted:

akismet.submitSpam(Akismet.jsonComment(json))