akismet

package
v0.0.0-...-0ca9e10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2018 License: MIT Imports: 7 Imported by: 15

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

func Check(c *Comment, key string) (bool, error)

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

func SubmitHam(c *Comment, key string) error

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

func SubmitSpam(c *Comment, key string) error

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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL