Skip to content

A GO Akismet client, made for easy use and testing

License

Notifications You must be signed in to change notification settings

Alkemic/akismet

Repository files navigation

akismet

A GO Akismet client, made for easy use and testing

Installation

$ go get github.com/Alkemic/akismet

Usage

Validate you key:

akismetClient, _ := akismet.NewClient("akismet-key", "http://some-blog.com")
ctx := context.Background()
validated, err := akismetClient.Valid(ctx)

if err != nil {
	// handle error
}

Check if comment is a SPAM:

akismetClient, _ := akismet.NewClient("akismet-key", "http://some-blog.com")
ctx := context.Background()
isSpam, err := akismetClient.Check(ctx, &akismet.Comment{
    Type:   "comment",
    Author: "John Doe",
    UserIP: "1.2.3.4",
})

if err != nil {
	// handle error
}

Submit SPAM:

akismetClient, _ := akismet.NewClient("akismet-key", "http://some-blog.com")
ctx := context.Background()
err := akismetClient.SubmitSpam(ctx, &akismet.Comment{
    Type:   "comment",
    Author: "John Doe",
    UserIP: "1.2.3.4",
})

if err != nil {
	// handle error
}

Submit HAM (aka false positive):

akismetClient, _ := akismet.NewClient("akismet-key", "http://some-blog.com")
ctx := context.Background()
err := akismetClient.SubmitHam(ctx, &akismet.Comment{
    Type:   "comment",
    Author: "John Doe",
    UserIP: "1.2.3.4",
})

if err != nil {
	// handle error
}

Advanced usage

You can use your own http.Client instance with calls to API, just use WithHttpClient functional option:

customHttpClient := &http.Client{
	// your options here
}
akismet.NewClient("akismet-key", "http://some-blog.com", WithHttpClient(customHttpClient))

About

A GO Akismet client, made for easy use and testing

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages