Akismet REST service implementation

uses
category Zend
package Zend_Service
subpackage Akismet
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_Service_Abstract

 Methods

Constructor

__construct(string $apiKey, string $blog) : void

Parameters

$apiKey

string

Akismet API key

$blog

string

Blog URL

Retrieve API key

getApiKey() : string

Returns

string

Retrieve blog URL

getBlogUrl() : string

Returns

string

Retrieve charset

getCharset() : string

Returns

string

Gets the HTTP client object.

getHttpClient() : \Zend_Http_Client
InheritedStatic

Returns

\Zend_Http_Client

Retrieve TCP/IP port

getPort() : integer

Returns

integer

Retrieve User Agent string

getUserAgent() : string

Returns

string

Check a comment for spam

isSpam(array $params) : boolean

Checks a comment to see if it is spam. $params should be an associative array with one or more of the following keys (unless noted, all keys are optional):

  • blog: URL of the blog. If not provided, uses value returned by \getBlogUrl()
  • user_ip (required): IP address of comment submitter
  • user_agent (required): User Agent used by comment submitter
  • referrer: contents of HTTP_REFERER header
  • permalink: location of the entry to which the comment was submitted
  • comment_type: typically, one of 'blank', 'comment', 'trackback', or 'pingback', but may be any value
  • comment_author: name submitted with the content
  • comment_author_email: email submitted with the content
  • comment_author_url: URL submitted with the content
  • comment_content: actual content

Additionally, Akismet suggests returning the key/value pairs in the $_SERVER array, and these may be included in the $params.

This method implements the Akismet comment-check REST method.

Parameters

$params

array

Exceptions

\Zend_Service_Exception with invalid API key

Returns

boolean

Set API key

setApiKey(string $apiKey) : \Zend_Service_Akismet

Parameters

$apiKey

string

Returns

\Zend_Service_Akismet

Set blog URL

setBlogUrl(string $blogUrl) : \Zend_Service_Akismet

Parameters

$blogUrl

string

Exceptions

\Zend_Service_Exception if invalid URL provided

Returns

\Zend_Service_Akismet

Set charset

setCharset(string $charset) : \Zend_Service_Akismet

Parameters

$charset

string

Returns

\Zend_Service_Akismet

Sets the HTTP client object to use for retrieving the feeds. If none is set, the default Zend_Http_Client will be used.

setHttpClient(\Zend_Http_Client $httpClient) 
InheritedStatic

Parameters

$httpClient

\Zend_Http_Client

Set TCP/IP port

setPort(integer $port) : \Zend_Service_Akismet

Parameters

$port

integer

Exceptions

\Zend_Service_Exception if non-integer value provided

Returns

\Zend_Service_Akismet

Set User Agent

setUserAgent(string $userAgent) : \Zend_Service_Akismet

Should be of form "Some user agent/version | Akismet/version"

Parameters

$userAgent

string

Exceptions

\Zend_Service_Exception with invalid user agent string

Returns

\Zend_Service_Akismet

Submit ham

submitHam(array $params) : void

Takes the same arguments as \isSpam().

Submits a comment that has been falsely categorized as spam by Akismet as a false positive, telling Akismet's filters not to filter such comments as spam in the future.

Unlike \submitSpam() and \isSpam(), a valid API key is never necessary; as a result, this method never throws an exception (unless an exception happens with the HTTP client layer).

this method implements Akismet's submit-ham REST method.

Parameters

$params

array

Submit spam

submitSpam(array $params) : void

Takes the same arguments as \isSpam().

Submits known spam content to Akismet to help train it.

This method implements Akismet's submit-spam REST method.

Parameters

$params

array

Exceptions

\Zend_Service_Exception with invalid API key

Verify an API key

verifyKey(string $key = null, string $blog = null) : boolean

Parameters

$key

string

Optional; API key to verify

$blog

string

Optional; blog URL against which to verify key

Returns

boolean

Perform an API call

_makeApiCall(string $path, array $params) : \Zend_Http_Response

Parameters

$path

string

$params

array

Exceptions

\Zend_Service_Exception if missing user_ip or user_agent fields

Returns

\Zend_Http_Response

Post a request

_post(string $host, string $path, array $params) : mixed

Parameters

$host

string

$path

string

$params

array

Returns

mixed

 Properties

 

Akismet API key

$_apiKey : string

Default

 

Blog URL

$_blogUrl : string

Default

 

Charset used for encoding

$_charset : string

Default

'UTF-8'
 

HTTP Client used to query all web services

$_httpClient : \Zend_Http_Client

Default

null
Static
 

TCP/IP port to use in requests

$_port : integer

Default

80
 

User Agent string to send in requests

$_userAgent : string

Default