Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content

Client library for accessing the Automattic Kismet (Akismet) spam comments filtering service

License

Notifications You must be signed in to change notification settings

ethauvin/akismet-kotlin

Repository files navigation

License (3-Clause BSD) Kotlin bld Release Maven Central Maven metadata URL

Quality Gate Status GitHub CI CircleCI

Akismet for Kotlin, Java and Android

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").apply {
    referrer = "https://www.google.com"
    type = CommentType.COMMENT
    author = "admin"
    authorEmail = "[email protected]"
    authorUrl = "https://www.CheckOutMyCoolSite.com"
    dateGmt = Akismet.dateToGmt(Date())
    content = "Thanks for reviewing our software."
}
// ...

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

View Full Examples

Java

final Akismet akismet = new Akismet("YOUR_API_KEY", "YOUR_BLOG_URL");
final AkismetComment comment = new AkismetComment(
    new CommentConfig.Builder("127.0.0.1", "curl/7.29.0")
            .referrer("https://www.google.com")
            .type(CommentType.COMMENT)
            .author("admin")
            .authorEmail("[email protected]")
            .authorUrl("https://www.CheckOutMyCoolSite.com")
            .dateGmt(Akismet.dateToGmt(new Date()))
            .content("Thanks for reviewing our software.")
            .build()
);
//...

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

View Full Examples

bld

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

repositories = List.of(MAVEN_CENTRAL, CENTRAL_SNAPSHOTS);

scope(compile)
    .include(dependency("net.thauvin.erik:akismet-kotlin:1.1.0-SNAPSHOT"));

Gradle

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

repositories {
    maven {
        name = 'Central Portal Snapshots'
        url = 'https://central.sonatype.com/repository/maven-snapshots/'
    }
    mavenCentral()
}

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

Instructions for using with Maven, Ivy, etc. can be found on Maven Central.

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

Contributing

See CONTIBUTING.md for information about contributing to this project.

More…

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

About

Client library for accessing the Automattic Kismet (Akismet) spam comments filtering service

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Languages