Service/Akismet.php
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 [email protected] 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 24593 2012-01-05 20:35:02Z matthew $
\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
- \global\Zend_Service_Abstract
Properties

\Zend_Http_Client $_httpClient = nullHTTP Client used to query all web services
Inherited from: \Zend_Service_Abstract::$$_httpClientnullDetails- Type
- \Zend_Http_Client
- Inherited_from
- \Zend_Service_Abstract::$$_httpClient
Methods

__construct(string $apiKey, string $blog) : voidConstructor
| Name | Type | Description |
|---|---|---|
| $apiKey | string | Akismet API key |
| $blog | string | Blog URL |

_makeApiCall(string $path, array $params) : \Zend_Http_ResponsePerform an API call
| Name | Type | Description |
|---|---|---|
| $path | string | |
| $params | array |
| Type | Description |
|---|---|
| \Zend_Http_Response |
| Exception | Description |
|---|---|
| \Zend_Service_Exception | if missing user_ip or user_agent fields |

_post(string $host, string $path, array $params) : mixedPost a request
| Name | Type | Description |
|---|---|---|
| $host | string | |
| $path | string | |
| $params | array |
| Type | Description |
|---|---|
| mixed |

getHttpClient() : \Zend_Http_ClientGets the HTTP client object.
Inherited from: \Zend_Service_Abstract::getHttpClient()| Type | Description |
|---|---|
| \Zend_Http_Client |

isSpam(array $params) : booleanCheck 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.
| Name | Type | Description |
|---|---|---|
| $params | array |
| Type | Description |
|---|---|
| boolean |
| Exception | Description |
|---|---|
| \Zend_Service_Exception | with invalid API key |

setApiKey(string $apiKey) : \Zend_Service_AkismetSet API key
| Name | Type | Description |
|---|---|---|
| $apiKey | string |
| Type | Description |
|---|---|
| \Zend_Service_Akismet |

setBlogUrl(string $blogUrl) : \Zend_Service_AkismetSet blog URL
| Name | Type | Description |
|---|---|---|
| $blogUrl | string |
| Type | Description |
|---|---|
| \Zend_Service_Akismet |
| Exception | Description |
|---|---|
| \Zend_Service_Exception | if invalid URL provided |

setCharset(string $charset) : \Zend_Service_AkismetSet charset
| Name | Type | Description |
|---|---|---|
| $charset | string |
| Type | Description |
|---|---|
| \Zend_Service_Akismet |

setHttpClient(\Zend_Http_Client $httpClient) : voidSets the HTTP client object to use for retrieving the feeds.
Inherited from: \Zend_Service_Abstract::setHttpClient()If none is set, the default Zend_Http_Client will be used.
| Name | Type | Description |
|---|---|---|
| $httpClient | \Zend_Http_Client |

setPort(int $port) : \Zend_Service_AkismetSet TCP/IP port
| Name | Type | Description |
|---|---|---|
| $port | int |
| Type | Description |
|---|---|
| \Zend_Service_Akismet |
| Exception | Description |
|---|---|
| \Zend_Service_Exception | if non-integer value provided |

setUserAgent(string $userAgent) : \Zend_Service_AkismetSet User Agent
Should be of form "Some user agent/version | Akismet/version"
| Name | Type | Description |
|---|---|---|
| $userAgent | string |
| Type | Description |
|---|---|
| \Zend_Service_Akismet |
| Exception | Description |
|---|---|
| \Zend_Service_Exception | with invalid user agent string |

submitHam(array $params) : voidSubmit 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.
| Name | Type | Description |
|---|---|---|
| $params | array |

submitSpam(array $params) : voidSubmit 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.
| Name | Type | Description |
|---|---|---|
| $params | array |
| Exception | Description |
|---|---|
| \Zend_Service_Exception | with invalid API key |