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
|
application
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ./gradlew run runJava
|
||||||
|
|
||||||
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
|
@ -34,13 +34,17 @@ public class AkismetSample {
|
||||||
final boolean hasBenSubmitted = akismet.submitSpam(comment);
|
final boolean hasBenSubmitted = akismet.submitSpam(comment);
|
||||||
if (hasBenSubmitted) {
|
if (hasBenSubmitted) {
|
||||||
System.out.println("The comment has been submitted as SPAM to Akismet");
|
System.out.println("The comment has been submitted as SPAM to Akismet");
|
||||||
|
} else {
|
||||||
|
System.err.println(akismet.getErrorMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
final boolean hasBeenSubmitted = akismet.submitHam(comment);
|
||||||
if (hasBeenSubmitted) {
|
if (hasBeenSubmitted) {
|
||||||
System.out.println("The comment has been submitted as HAM to Akismet");
|
System.out.println("The comment has been submitted as HAM to Akismet");
|
||||||
|
} else {
|
||||||
|
System.err.println(akismet.getErrorMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -8,10 +8,11 @@ fun main() {
|
||||||
val akismet = Akismet("YOUR_API_KEY", "YOUR_BLOG_URL")
|
val akismet = Akismet("YOUR_API_KEY", "YOUR_BLOG_URL")
|
||||||
val comment = AkismetComment(
|
val comment = AkismetComment(
|
||||||
userIp = "127.0.0.1",
|
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.isTest = true
|
||||||
|
|
||||||
comment.referrer = "http://www.google.com"
|
comment.referrer = "http://www.google.com"
|
||||||
comment.permalink = "http://yourblogdomainname.com/blog/post=1"
|
comment.permalink = "http://yourblogdomainname.com/blog/post=1"
|
||||||
comment.type = AkismetComment.TYPE_COMMENT
|
comment.type = AkismetComment.TYPE_COMMENT
|
||||||
|
@ -35,6 +36,8 @@ fun main() {
|
||||||
|
|
||||||
if (hasBeenSubmitted) {
|
if (hasBeenSubmitted) {
|
||||||
println("The comment was successfully submitted as SPAM to Akismet.")
|
println("The comment was successfully submitted as SPAM to Akismet.")
|
||||||
|
} else {
|
||||||
|
System.err.println(akismet.errorMessage)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println("The comment is not SPAM (HAM) according to Akismet.")
|
println("The comment is not SPAM (HAM) according to Akismet.")
|
||||||
|
@ -43,6 +46,8 @@ fun main() {
|
||||||
|
|
||||||
if (hasBeenSubmitted) {
|
if (hasBeenSubmitted) {
|
||||||
println("The comment was successfully submitted as HAM to Akismet.")
|
println("The comment was successfully submitted as HAM to Akismet.")
|
||||||
|
} else {
|
||||||
|
System.err.println(akismet.errorMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue