diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index 080087d..19960b1 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -3,6 +3,8 @@ plugins { application } +// ./gradlew run runJava + defaultTasks(ApplicationPlugin.TASK_RUN_NAME) repositories { diff --git a/examples/src/main/java/com/example/AkismetSample.java b/examples/src/main/java/com/example/AkismetSample.java index fb8adf5..503f63a 100644 --- a/examples/src/main/java/com/example/AkismetSample.java +++ b/examples/src/main/java/com/example/AkismetSample.java @@ -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 { diff --git a/examples/src/main/kotlin/com/example/AkismetExample.kt b/examples/src/main/kotlin/com/example/AkismetExample.kt index 8acf680..099834a 100644 --- a/examples/src/main/kotlin/com/example/AkismetExample.kt +++ b/examples/src/main/kotlin/com/example/AkismetExample.kt @@ -8,10 +8,11 @@ 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 - + comment.referrer = "http://www.google.com" comment.permalink = "http://yourblogdomainname.com/blog/post=1" comment.type = AkismetComment.TYPE_COMMENT @@ -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 {