matthewbdaly/akismet-client

0.1.0 2018-01-09 23:14 UTC

This package is auto-updated.

Last update: 2024-10-28 07:39:34 UTC


README

Build Status

A PHP client for the Akismet spam detection service. Built using modern practices and with an extensive test suite.

Installation

Install it with the following command:

composer require matthewbdaly/akismet-client

This library use HTTPlug, so you will also need to install a client implementation as specified here in order to actually use this client.

Usage

The client offers the following methds:

  • setKey($key) - Sets the API key
  • getKey() - Gets the API key
  • setBlog($blog) - Sets the blog URL
  • getBlog() - Gets the blog URL
  • setIp($ip) - Sets the user IP address
  • getIp() - Gets the user IP address
  • setAgent($agent) - Sets the user agent string
  • getAgent() - Gets the user agent string
  • setReferrer($referrer) - Sets the referrer URL
  • getReferrer() - Gets the referrer URL
  • setPermalink($permalink) - Sets the permalink to the post
  • getPermalink() - Gets the permalink to the post
  • setCommentType($type) - Sets the comment type - can be comment, forum-post, reply, blog-post, contact-form, signup, message or a custom type
  • getCommentType() - Gets the comment type
  • setCommentAuthor($author) - Sets the comment author
  • getCommentAuthor() - Gets the comment author
  • setCommentAuthorEmail($email) - Sets the comment author email
  • getCommentAuthorEmail() - Gets the comment author email
  • setCommentAuthorUrl($url) - Sets the comment author url
  • getCommentAuthorUrl() - Gets the comment author url
  • setCommentContent($content) - Sets the comment content
  • getCommentContent() - Gets the comment content
  • setCommentDateGMT($date) - Sets the comment date
  • getCommentDate() - Gets the comment date
  • setCommentPostModifiedDate($date) - Sets the comment modified date
  • getCommentPostModifiedDate() - Gets the comment modified date
  • setBlogLang($lang) - Sets the blog language
  • getBlogLang() - Gets the blog language
  • setBlogCharset($charset) - Sets the blog charset
  • getBlogCharset() - Gets the blog charset
  • setUserRole($role) - Sets the user role
  • getUserRole() - Gets the user role
  • setIsTest($test) - Sets whether this is a test
  • getIsTest() - Gets whether this is a test
  • flush() - Flush all the existing values
  • verifyKey() - Verify the currently set API key
  • check() - Check the currently set comment to see if it is spam
  • spam() - Submit comment to Akisment as spam
  • ham() - Submit comment to Akisment as ham
  • setParams(array $params) - Set parameters in bulk

All of the set() methods and the flush() method are chainable, so you can do something like this:

$client->setParams($params)
    ->setCommentType('comment')
    ->setCommentAuthor('Bob Smith')
    ->check();

Note that verifyKey(), check(), ham() and spam() do not flush the parameters, so ensure you do so before starting a new request.