Zend Framework  1.12
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Zend_Service_Akismet Class Reference

Public Member Functions

 __construct ($apiKey, $blog)
 Constructor.
 
 getBlogUrl ()
 Retrieve blog URL.
 
 setBlogUrl ($blogUrl)
 Set blog URL.
 
 getApiKey ()
 Retrieve API key.
 
 setApiKey ($apiKey)
 Set API key.
 
 getCharset ()
 Retrieve charset.
 
 setCharset ($charset)
 Set charset.
 
 getPort ()
 Retrieve TCP/IP port.
 
 setPort ($port)
 Set TCP/IP port.
 
 getUserAgent ()
 Retrieve User Agent string.
 
 setUserAgent ($userAgent)
 Set User Agent.
 
 verifyKey ($key=null, $blog=null)
 Verify an API key.
 
 isSpam ($params)
 Check a comment for spam.
 
 submitSpam ($params)
 Submit spam.
 
 submitHam ($params)
 Submit ham.
 

Protected Member Functions

 _post ($host, $path, array $params)
 Post a request.
 
 _makeApiCall ($path, $params)
 Perform an API call.
 

Protected Attributes

 $_apiKey
 
 $_blogUrl
 
 $_charset = 'UTF-8'
 
 $_port = 80
 
 $_userAgent
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Service_Abstract
static setHttpClient (Zend_Http_Client $httpClient)
 Sets the HTTP client object to use for retrieving the feeds.
 
static getHttpClient ()
 Gets the HTTP client object.
 
- Static Protected Attributes inherited from Zend_Service_Abstract
static $_httpClient = null
 

Constructor & Destructor Documentation

__construct (   $apiKey,
  $blog 
)

Constructor.

Parameters
string$apiKeyAkismet API key
string$blogBlog URL
Returns
void

Member Function Documentation

_makeApiCall (   $path,
  $params 
)
protected

Perform an API call.

Parameters
string$path
array$params
Returns
Zend_Http_Response
Exceptions
Zend_Service_Exceptionif missing user_ip or user_agent fields
_post (   $host,
  $path,
array  $params 
)
protected

Post a request.

Parameters
string$host
string$path
array$params
Returns
mixed
getApiKey ( )

Retrieve API key.

Returns
string
getBlogUrl ( )

Retrieve blog URL.

Returns
string
getCharset ( )

Retrieve charset.

Returns
string
getPort ( )

Retrieve TCP/IP port.

Returns
int
getUserAgent ( )

Retrieve User Agent string.

Returns
string
isSpam (   $params)

Check a comment for spam.

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
array$params
Returns
boolean
Exceptions
Zend_Service_Exceptionwith invalid API key
setApiKey (   $apiKey)

Set API key.

Parameters
string$apiKey
Returns
Zend_Service_Akismet
setBlogUrl (   $blogUrl)

Set blog URL.

Parameters
string$blogUrl
Returns
Zend_Service_Akismet
Exceptions
Zend_Service_Exceptionif invalid URL provided
setCharset (   $charset)

Set charset.

Parameters
string$charset
Returns
Zend_Service_Akismet
setPort (   $port)

Set TCP/IP port.

Parameters
int$port
Returns
Zend_Service_Akismet
Exceptions
Zend_Service_Exceptionif non-integer value provided
setUserAgent (   $userAgent)

Set User Agent.

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

Parameters
string$userAgent
Returns
Zend_Service_Akismet
Exceptions
Zend_Service_Exceptionwith invalid user agent string
submitHam (   $params)

Submit ham.

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
array$params
Returns
void
submitSpam (   $params)

Submit spam.

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
array$params
Returns
void
Exceptions
Zend_Service_Exceptionwith invalid API key
verifyKey (   $key = null,
  $blog = null 
)

Verify an API key.

Parameters
string$keyOptional; API key to verify
string$blogOptional; blog URL against which to verify key
Returns
boolean

Member Data Documentation

$_apiKey
protected
$_blogUrl
protected
$_charset = 'UTF-8'
protected
$_port = 80
protected
$_userAgent
protected