Improved examples.
This commit is contained in:
parent
1595c7c238
commit
9e6507392e
3 changed files with 14 additions and 3 deletions
|
@ -3,6 +3,8 @@ plugins {
|
|||
application
|
||||
}
|
||||
|
||||
// ./gradlew run runJava
|
||||
|
||||
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
||||
|
||||
repositories {
|
||||
|
|
|
@ -34,13 +34,17 @@ public class AkismetSample {
|
|||
final boolean hasBenSubmitted = akismet.submitSpam(comment);
|
||||
if (hasBenSubmitted) {
|
||||
System.out.println("The comment has been submitted as SPAM to Akismet");
|
||||
} else {
|
||||
System.err.println(akismet.getErrorMessage());
|
||||
}
|
||||
} else {
|
||||
System.out.println("The comment is not SPAM (HAM) according to Akismet.");
|
||||
System.out.println("The comment is not SPAM according to Akismet.");
|
||||
|
||||
final boolean hasBeenSubmitted = akismet.submitHam(comment);
|
||||
if (hasBeenSubmitted) {
|
||||
System.out.println("The comment has been submitted as HAM to Akismet");
|
||||
} else {
|
||||
System.err.println(akismet.getErrorMessage());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -8,7 +8,8 @@ fun main() {
|
|||
val akismet = Akismet("YOUR_API_KEY", "YOUR_BLOG_URL")
|
||||
val comment = AkismetComment(
|
||||
userIp = "127.0.0.1",
|
||||
userAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6")
|
||||
userAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6"
|
||||
)
|
||||
|
||||
comment.isTest = true
|
||||
|
||||
|
@ -35,6 +36,8 @@ fun main() {
|
|||
|
||||
if (hasBeenSubmitted) {
|
||||
println("The comment was successfully submitted as SPAM to Akismet.")
|
||||
} else {
|
||||
System.err.println(akismet.errorMessage)
|
||||
}
|
||||
} else {
|
||||
println("The comment is not SPAM (HAM) according to Akismet.")
|
||||
|
@ -43,6 +46,8 @@ fun main() {
|
|||
|
||||
if (hasBeenSubmitted) {
|
||||
println("The comment was successfully submitted as HAM to Akismet.")
|
||||
} else {
|
||||
System.err.println(akismet.errorMessage)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue