Added Gradle section.
This commit is contained in:
parent
187ae6718e
commit
ba714a3e9f
2 changed files with 21 additions and 7 deletions
27
README.md
27
README.md
|
@ -1,9 +1,9 @@
|
|||
[](http://opensource.org/licenses/BSD-3-Clause)
|
||||
[](http://opensource.org/licenses/BSD-3-Clause) [](https://github.com/ethauvin/akismet-kotlin/releases/latest) [](https://maven-badges.herokuapp.com/maven-central/net.thauvin.erik/akismet-kotlin) [](https://bintray.com/ethauvin/maven/akismet-kotlin/_latestVersion) \
|
||||
[](https://snyk.io/test/github/ethauvin/akismet-kotlin?targetFile=pom.xml) [](https://sonarcloud.io/dashboard?id=ethauvin_akismet-kotlin) [](https://travis-ci.com/ethauvin/akismet-kotlin) [](https://circleci.com/gh/ethauvin/akismet-kotlin/tree/master)
|
||||
|
||||
# [Akismet](https://www.akismet.com) for Kotlin/Java
|
||||
|
||||
Akismet for Kotlin/Java is a pretty complete and straightforward implementation of the [Automattic's Akismet](https://akismet.com/development/api/) API, a free service that can be used to actively stop comments spam.
|
||||
Akismet for Kotlin/Java is a pretty complete and straightforward implementation of the [Automattic's Akismet](https://akismet.com/development/api/) API, a free service which can be used to actively stop comments spam.
|
||||
|
||||
## Examples (TL;DR)
|
||||
|
||||
|
@ -55,18 +55,33 @@ if (isSpam) {
|
|||
|
||||
[View Full Example](https://github.com/ethauvin/akismet-kotlin/blob/master/examples/src/main/java/com/example/AkismetSample.java)
|
||||
|
||||
|
||||
### Gradle
|
||||
|
||||
To use with [Gradle](https://gradle.org/), include the following dependency in your [build](https://github.com/ethauvin/akismet-kotlin/blob/master/examples/build.gradle.kts) file:
|
||||
|
||||
```gradle
|
||||
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](https://javaee.github.io/javaee-spec/javadocs/javax/servlet/http/HttpServletRequest.html) can be used as a parameter so that all of the relevant information is automatically included.
|
||||
The more information is sent to Akismet, the more accurate the response is. An [HttpServletRequest](https://javaee.github.io/javaee-spec/javadocs/javax/servlet/http/HttpServletRequest.html) can be used as a parameter so that all the relevant information is automatically included.
|
||||
|
||||
```kotlin
|
||||
AkismetComment(request = context.getRequest())
|
||||
```
|
||||
|
||||
[View Full Example](https://github.com/ethauvin/akismet-kotlin/blob/master/examples/src/main/kotlin/com/example/AkismetServlet.kt)
|
||||
|
||||
This will ensure that the user's IP, agent, referrer and various environment variables are automatically extracted from the request.
|
||||
|
||||
[View Full Example](https://github.com/ethauvin/akismet-kotlin/blob/master/examples/src/main/kotlin/com/example/AkismetServlet.kt)
|
||||
|
||||
### 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.
|
||||
|
@ -75,7 +90,7 @@ Since comments mis-identified as spam or ham can be submitted to Askimet to impr
|
|||
var json = comment.toJson()
|
||||
```
|
||||
|
||||
At a latter time, the comment can the be submitted:
|
||||
At a latter time, the comment can then be submitted:
|
||||
|
||||
```kotlin
|
||||
akismet.submitSpam(Akismet.jsonComment(json))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue