akismet

package module
v0.0.0-...-376895e Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2015 License: GPL-2.0 Imports: 6 Imported by: 0

README

akismet-go

Build Status Coverage Status Code Climate GoDoc License

Go utils for working with Akismet spam detection service.

Examples

Example 1 - Verification Client
package main

import (
	"fmt"
	"github.com/SebastianCzoch/akismet-go"
)

func main() {
	client := akismet.NewClient("api_key", "site")
	if client.VeryfiClient() != nil {
		fmt.Println("Client can't be verified, ", err)
	}
}
Example 2 - Check spam
package main

import (
	"fmt"
	"github.com/SebastianCzoch/akismet-go"
)

func main() {
	client := akismet.NewClient("api_key", "site")
	if client.VeryfiClient() != nil {
		fmt.Println("Client can't be verified, ", err)
	}

	options := akismet.Options{
		UserIP: "127.0.0.1",
		UserAgent: "Test-Agent",
		Content: "It's a spam?",
	}

	isSpam, err := client.IsSpam(options)
	if err != nil {
		fmt.Println(err)
	}

	if isSpam {
		fmt.Println("This is spam")
	} else {
		fmt.Println("This is not spam")
	}
}

Install

$ go get github.com/SebastianCzoch/akismet-go

or via Godep

$ godep get github.com/SebastianCzoch/akismet-go

API

NewClient(apiKey, site string) *Client

Create new client and return pointer to it

(c *Client) VeryfiClient() (error)

Check if passed key and blog values are correct, if not return error

(c *Client) IsSpam(o Options) (bool, error)

Check if passed Options struct is a spam or not

(c *Client) SubmitSpam(o Options) error

This call is for submitting comments that weren't marked as spam but should have been.

(c *Client) SubmitHam(o Options) error

This call is intended for the submission of false positives - items that were incorrectly classified as spam by Akismet.

Options struct
	UserIP      string (required) IP address of the comment submitter
	UserAgent   string (required) User agent string of the web browser submitting the comment
	Referrer    string The content of the HTTP_REFERER header should be sent here
	Permalink   string The permanent location of the entry the comment was submitted to
	Author      string Name submitted with the comment
	AuthorEmail string Email address submitted with the comment
	AuthorURL   string URL submitted with comment
	Content     string The content that was submitted
	Created     string Datetime when content was created (RFC 3339 format)
	Modified    string Datetime when content was modified (RFC 3339 format)
	Lang        string Indicates the language(s) in use on the blog or site, in ISO 639-1 format, comma-separated. A site with articles in English and French might use "en, fr_ca"
	Charset     string The character encoding for the form values, such as "UTF-8" or "ISO-8859-1"
	UserRole    string The user role of the user who submitted the comment. This is an optional parameter. If you set it to "administrator", Akismet will always return false.
	IsTest      string This is an optional parameter. You can use it when submitting test queries to Akismet.

Tests

Required go in version >=1.4

$ go test ./...

License

GNU v2

Support

Issues for this project should be reported on GitHub issues

Staff responsible for project:

Documentation

Overview

Package akismet is Go utils for working with Akismet spam detection service

Index

Constants

View Source
const (
	APIAddress              = "rest.akismet.com"
	APIProtocol             = "https"
	APIVersion              = "1.1"
	DateFormat              = time.RFC3339
	SubmitResponseContentOK = "Thanks for making the web a better place."
)

Basic informations about Akismet API

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is Akismet client struct

func NewClient

func NewClient(apiKey, site string) *Client

NewClient is function which create new Akismet client

func (*Client) IsSpam

func (c *Client) IsSpam(o Options) (bool, error)

IsSpam is a method which check if passed Options struct is spam or not

func (*Client) SubmitHam

func (c *Client) SubmitHam(o Options) error

SubmitHam is method which send to Akismet API request about found ham

func (*Client) SubmitSpam

func (c *Client) SubmitSpam(o Options) error

SubmitSpam is method which send to Akismet API request about found spam

func (*Client) VeryfiClient

func (c *Client) VeryfiClient() error

VeryfiClient is method which check key & site parameters are valid

type Options

type Options struct {
	UserIP      string
	UserAgent   string
	Referrer    string
	Permalink   string
	Author      string
	AuthorEmail string
	AuthorURL   string
	Content     string
	Created     string
	Modified    string
	Lang        string
	Charset     string
	UserRole    string
	IsTest      string
}

Options is a struct which contains all of possible arguments for Akismet

Directories

Path Synopsis
Godeps
_workspace/src/github.com/jarcoal/httpmock
HTTPmock provides tools for mocking HTTP responses.
HTTPmock provides tools for mocking HTTP responses.
_workspace/src/github.com/stretchr/testify/assert
Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.

Jump to

Keyboard shortcuts

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