akismet-kotlin

Akismet for Kotlin/Java, a client library for accessing the Automattic Kismet (Akismet) spam comments filtering service.

License

License

Categories

Categories

Kotlin Languages Net
GroupId

GroupId

net.thauvin.erik
ArtifactId

ArtifactId

akismet-kotlin
Last Version

Last Version

0.9.2
Release Date

Release Date

Type

Type

jar
Description

Description

akismet-kotlin
Akismet for Kotlin/Java, a client library for accessing the Automattic Kismet (Akismet) spam comments filtering service.
Project URL

Project URL

https://github.com/ethauvin/akismet-kotlin
Source Code Management

Source Code Management

https://github.com/ethauvin/akismet-kotlin

Download akismet-kotlin

How to add to project

<!-- https://jarcasting.com/artifacts/net.thauvin.erik/akismet-kotlin/ -->
<dependency>
    <groupId>net.thauvin.erik</groupId>
    <artifactId>akismet-kotlin</artifactId>
    <version>0.9.2</version>
</dependency>
// https://jarcasting.com/artifacts/net.thauvin.erik/akismet-kotlin/
implementation 'net.thauvin.erik:akismet-kotlin:0.9.2'
// https://jarcasting.com/artifacts/net.thauvin.erik/akismet-kotlin/
implementation ("net.thauvin.erik:akismet-kotlin:0.9.2")
'net.thauvin.erik:akismet-kotlin:jar:0.9.2'
<dependency org="net.thauvin.erik" name="akismet-kotlin" rev="0.9.2">
  <artifact name="akismet-kotlin" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.thauvin.erik', module='akismet-kotlin', version='0.9.2')
)
libraryDependencies += "net.thauvin.erik" % "akismet-kotlin" % "0.9.2"
[net.thauvin.erik/akismet-kotlin "0.9.2"]

Dependencies

runtime (5)

Group / Artifact Type Version
javax.servlet : javax.servlet-api jar 4.0.1
com.squareup.okhttp3 : okhttp jar 4.7.2
com.squareup.okhttp3 : logging-interceptor jar 4.7.2
org.jetbrains.kotlin : kotlin-stdlib jar 1.3.72
org.jetbrains.kotlinx : kotlinx-serialization-runtime jar 0.20.0-1.3.70-eap-274-2

Project Modules

There are no modules declared in this project.

License (3-Clause BSD) release Maven Central Download

Known Vulnerabilities Quality Gate Status Build Status CircleCI

Akismet for Kotlin/Java

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

Examples (TL;DR)

Kotlin

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

with(comment) {
    referrer = "http://www.google.com"
    type = AkismetComment.TYPE_COMMENT
    author = "admin"
    authorEmail = "[email protected]"
    authorUrl = "http://www.CheckOutMyCoolSite.com"
    dateGmt = Akismet.dateToGmt(Date())
    content = "It means a lot that you would take the time to review our software."
}
// ...

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

View Full Example

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("[email protected]");
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) {
    // ...
}

View Full Example

Gradle

To use with Gradle, include the following dependency in your build file:

repositories {
    jcenter()
}

dependencies {
    implementation("net.thauvin.erik:akismet-kotlin:0.9.2")
}

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 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.

View Full Example

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.toJson()

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

akismet.submitSpam(Akismet.jsonComment(json))

More...

If all else fails, there's always more Documentation.

Versions

Version
0.9.2