Coder Social home page Coder Social logo

akismet-go's Introduction

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:

akismet-go's People

Contributors

golint-fixer avatar sebastianczoch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.