akismet

package
v1.7.12 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommentCheck

func CommentCheck(config *Config, comment Comment) error

CommentCheck submits the given comment to Akismet, and returns nil if the comment isn't spam; errSpam if it is; errInvalidRequest if the comment or configuration is incorrect; and errUnknown otherwise.

func CommentSubmitHam

func CommentSubmitHam(config *Config, comment Comment) error

CommentSubmitHam submits the given comment to Akismet as Ham Returns nil if the submission was successful, or errUnknown otherwise.

func CommentSubmitSpam

func CommentSubmitSpam(config *Config, comment Comment) error

CommentSubmitSpam submits the given comment to Akismet as Spam Returns nil if the submission was successful, or errUnknown otherwise.

func UserAgentString

func UserAgentString(application string) string

UserAgentString constructs a user agent string suitable for use with akismet, based on their recommendations here. See 'Setting your user agent' for more information: http://akismet.com/development/api/#getting-started

func VerifyKey

func VerifyKey(config *Config) error

VerifyKey checks the configuration with Akismet. This should be performed at application startup, otherwise future api calls may fail due to invalid configuration Returns nil if the configuration is valid; returns errInvalidKey if it is not; returns errUnknown otherwise.

Types

type Comment

type Comment struct {
	UserIP      string
	UserAgent   string
	Referrer    string
	Permalink   string
	Type        string
	Author      string
	AuthorEmail string
	AuthorURL   string
	Content     string
}

Comment represents a single user comment to be checked and submitted with Akismet. The UserIP and UserAgent fields are the only two required fields, although for best results you should fill in as much of this info as possible. The fields are explained in more detail here: http://akismet.com/development/api/#comment-check

func (*Comment) MakePOST

func (comment *Comment) MakePOST(config *Config, url string) (resp *http.Response, err error)

MakePOST builds a POST request to a given URL containing the Comment object as POST data. It returns the http response, and any errors.

type Config

type Config struct {
	APIKey    string
	Host      string
	UserAgent string
}

Config is a struct containing akismet configuration unique to each application.

func (*Config) CommentCheckURL

func (c *Config) CommentCheckURL() string

CommentCheckURL returns the akismet api's comment check URL

func (*Config) SubmitHamURL

func (c *Config) SubmitHamURL() string

SubmitHamURL returns the akismet api's ham submission URL

func (*Config) SubmitSpamURL

func (c *Config) SubmitSpamURL() string

SubmitSpamURL returns the akismet api's spam submission URL

func (*Config) VerifyKeyURL

func (c *Config) VerifyKeyURL() string

VerifyKeyURL returns the akismet api's key verification URL

Jump to

Keyboard shortcuts

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