Documentation ¶
Overview ¶
The akismet package provides a client for using the Akismet API.
Usage:
import "github.com/adtac/go-akismet/akismet"
Here's an example if you want to check whether a particular comment is spam or not using the akismet.Check method:
akismetKey := "abcdef012345" isSpam, err := akismet.Check(akismet.Comment{ Blog: "https://example.com", // required UserIP: "8.8.8.8", // required UserAgent: "...", // required CommentType: "comment", CommentAuthor: "Billie Joe", CommentAuthorEmail: "billie@example.com", CommentContent: "Something's on my mind", }, akismetKey) if err != nil { // There was some issue with the API request. Most probable cause is // missing required fields. }
You can also submit false positives (comments that were wrongly marked as spam) with the akismet.SubmitHam method. Or you can submit false negatives (comments that should be marked as spam, but weren't) with the akismet.SubmitSpam method. Both methods have the same method signature as the akismet.Check function: an akismet.Comment structure as the first argument followed by your API key.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
This function checks whether a particular Comment is spam or not by querying the Akismet API. The returned boolean is true if the comment was classified as spam, false otherwise. If the request failed for whatever reason, the error returned will be non-nil.
func SubmitHam ¶
This function submits a false positive to Akismet using the API. False positives are those comments that should *not* be marked as spam, but were accidentally. This method is mandatorily required in all implementations. If the request went fine, a nil error is returned. Otherwise the returned error is non-nil.
func SubmitSpam ¶
This function submits a false negatives to Akismet using the API. False negatives are those comments that should be marked as spam, but were *not* accidentally. This method is mandatorily required in all implementations. If the request went fine, a nil error is returned. Otherwise the returned error is non-nil.
Types ¶
type Comment ¶
type Comment struct { Blog string `form:"blog"` UserIP string `form:"user_ip"` UserAgent string `form:"user_agent"` Referrer string `form:"referrer"` Permalink string `form:"permalink"` CommentType string `form:"comment_type"` CommentAuthor string `form:"comment_author"` CommentAuthorEmail string `form:"comment_author_email"` CommentAuthorURL string `form:"comment_author_url"` CommentContent string `form:"comment_content"` BlogLang string `form:"blog_lang"` BlogCharset string `form:"blog_charset"` UserRole string `form:"user_role"` }