API Documentation

Zend/Service/Akismet.php

Show: inherited
Table of Contents

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Service  
Subpackage
Akismet  
Version
$Id: Akismet.php 24594 2012-01-05 21:27:01Z matthew $  

\Zend_Service_Akismet

Package: Zend\Service\Akismet

Akismet REST service implementation

Parent(s)
\Zend_Service_Abstract
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Uses
\Zend_Service_Abstract  

Properties

Propertyprotectedstring  $_apiKey= ''

Akismet API key

Details
Type
string
Propertyprotectedstring  $_blogUrl= ''

Blog URL

Details
Type
string
Propertyprotectedstring  $_charset= ''UTF-8''

Charset used for encoding

Default value'UTF-8'Details
Type
string
Propertyprotectedint  $_port= '80'

TCP/IP port to use in requests

Default value80Details
Type
int
Propertyprotectedstring  $_userAgent= ''

User Agent string to send in requests

Details
Type
string

Methods

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

Constructor

Parameters
Name Type Description
$apiKey string

Akismet API key

$blog string

Blog URL

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

Perform an API call

Parameters
Name Type Description
$path string
$params array
Returns
Type Description
\Zend_Http_Response
Throws
Exception Description
\Zend_Service_Exception if missing user_ip or user_agent fields
methodprotected_post( string $host, string $path, array $params ) : mixed

Post a request

Parameters
Name Type Description
$host string
$path string
$params array
Returns
Type Description
mixed
methodpublicgetApiKey( ) : string

Retrieve API key

Returns
Type Description
string
methodpublicgetBlogUrl( ) : string

Retrieve blog URL

Returns
Type Description
string
methodpublicgetCharset( ) : string

Retrieve charset

Returns
Type Description
string
methodpublicgetPort( ) : int

Retrieve TCP/IP port

Returns
Type Description
int
methodpublicgetUserAgent( ) : string

Retrieve User Agent string

Returns
Type Description
string
methodpublicisSpam( array $params ) : boolean

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 {@link 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
Name Type Description
$params array
Returns
Type Description
boolean
Throws
Exception Description
\Zend_Service_Exception with invalid API key
methodpublicsetApiKey( string $apiKey ) : \Zend_Service_Akismet

Set API key

Parameters
Name Type Description
$apiKey string
Returns
Type Description
\Zend_Service_Akismet
methodpublicsetBlogUrl( string $blogUrl ) : \Zend_Service_Akismet

Set blog URL

Parameters
Name Type Description
$blogUrl string
Returns
Type Description
\Zend_Service_Akismet
Throws
Exception Description
\Zend_Service_Exception if invalid URL provided
methodpublicsetCharset( string $charset ) : \Zend_Service_Akismet

Set charset

Parameters
Name Type Description
$charset string
Returns
Type Description
\Zend_Service_Akismet
methodpublicsetPort( int $port ) : \Zend_Service_Akismet

Set TCP/IP port

Parameters
Name Type Description
$port int
Returns
Type Description
\Zend_Service_Akismet
Throws
Exception Description
\Zend_Service_Exception if non-integer value provided
methodpublicsetUserAgent( string $userAgent ) : \Zend_Service_Akismet

Set User Agent

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

Parameters
Name Type Description
$userAgent string
Returns
Type Description
\Zend_Service_Akismet
Throws
Exception Description
\Zend_Service_Exception with invalid user agent string
methodpublicsubmitHam( array $params ) : void

Submit ham

Takes the same arguments as {@link 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 {@link submitSpam()} and {@link 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
Name Type Description
$params array
methodpublicsubmitSpam( array $params ) : void

Submit spam

Takes the same arguments as {@link isSpam()}.

Submits known spam content to Akismet to help train it.

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

Parameters
Name Type Description
$params array
Throws
Exception Description
\Zend_Service_Exception with invalid API key
methodpublicverifyKey( string $key = null, string $blog = null ) : boolean

Verify an API key

Parameters
Name Type Description
$key string

Optional; API key to verify

$blog string

Optional; blog URL against which to verify key

Returns
Type Description
boolean
Documentation was generated by DocBlox 0.15.1.